MySQL库文件怎么设置 mysql怎么设置保存点( 三 )


[root@test1 mysql]# cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
5、编辑MySQL的配置文件/etc/my.cnf
为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置 。修改socket=/var/lib/mysql/mysql.sock一行中等号右边的值为:/home/mysql/mysql.sock 。操作如下:
vimy.cnf(用vi工具编辑my.cnf文件,找到下列数据修改之)
# The MySQL server
[mysqld]
port = 3306
#socket= /var/lib/mysql/mysql.sock(原内容,为了更稳妥用“#”注释此行)
socket= /home/data/mysql/mysql.sock (加上此行)
6、修改MySQL启动脚本/etc/init.d/mysql
最后 , 需要修改MySQL启动脚本/etc/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在的实际存放路径:home/data/mysql 。
[root@test1 etc]# vi /etc/init.d/mysql
#datadir=/var/lib/mysql(注释此行)
datadir=/home/data/mysql (加上此行)
7、重新启动MySQL服务
/etc/init.d/mysql start
或用reboot命令重启Linux
如果工作正常移动就成功了,否则对照前面的7步再检查一下 。
还要注意目录的属主和权限 。
怎么配置mysql数据库配置文件一、mysql_install_db说明
当MySQL的系统库(mysql系统库)发生故障或需要新加一个mysql实例时MySQL库文件怎么设置,需要初始化mysql数据库 。
需要使用的命令MySQL库文件怎么设置:/usr/local/mysql/bin/mysql_install_db
#/usr/local/mysql/bin/mysql_install_db --help 可以查看帮助信息如下
Usage: /usr/local/mysql/bin/mysql_install_db [OPTIONS]
--basedir=pathThe path to the MySQL installation directory.
--cross-bootstrapFor internal use.Used when building the MySQL system
tables on a different host than the target.
--datadir=pathThe path to the MySQL data directory.
--forceCauses mysql_install_db to run even if DNS does not
work.In that case, grant table entries that normally
use hostnames will use IP addresses.
--ldata=https://www.04ip.com/post/pathThe path to the MySQL data directory.
--rpmFor internal use.This option is used by RPM files
during the MySQL installation process.
--skip-name-resolveUse IP addresses rather than hostnames when creating
grant table entries.This option can be useful if
your DNS does not work.
--srcdir=pathFor internal use.The directory under which
mysql_install_db looks for support files such as the
error message file and the file for popoulating the
help tables.
--user=user_nameThe login username to use for running mysqld.Files
and directories created by mysqld will be owned by this
user.You must be root to use this option.By default
mysqld runs using your current login name and files and
directories that it creates will be owned by you.
All other options are passed to the mysqld program
除了支持以上的参数MySQL库文件怎么设置,还支持mysqld的参数 。
二、举例:
本文以新加一个mysql实例为例 。例如服务器上已经安装了3306端口的mysql服务,需要再启一个3308端口的mysql服务 。
假设mysql安装在/usr/local/mysql路径下,找一个磁盘空间剩余比较大的盘,如/data1,把3308端口的mysql的数据保存在/data1下
#mkdir /data1/mysql_3308
#mkdir /data1/mysql_3308/data
#chown -R mysql:mysql /data1/mysql_3308
复制一个mysql配置文件my.cnf到/data1/mysql_3308目录下
#vi /data1/mysql_3308/my.cnf
修改配置文件,将端口和相关目录的都改为新的设置,如下:
[client]
character-set-server = utf8
port= 3308
socket= /tmp/mysql_3308.sock
[mysqld]
user= mysql
port= 3308
socket= /tmp/mysql_3308.sock
basedir = /usr/local/mysql
datadir = /data1/mysql_3308/data

推荐阅读