1.设置mysql开机自启动
1.1.安装完成后制作服务,开机自动启动
A ../mysql.server拷入到/etc/init.d/mysqld
*关于启动脚本的制作,原理就是在里面调用启动程序
*如为/usr/bin/scim脚本设置启动脚本,启动脚本的内容可简略为:
#!/bin/bash /usr/bin/scim
B. 启动mysql服务器
C. chkconfig –add mysqld(取名为mysql service方法启动不了 可能是apt安装时御用mysql服务名为mysql)
service xxx start/stop 即可生效,重启后失效
chkconfig xxx on/off 重启后永久生效
如果没有安装chkconfig可手动设置服务自动启动。
在/etc/rc*.d/目录下建立/etc/init.d/mysqld的软连接
如:ln -s /etc/init.d/mysqld /etc/rc0.d/S77mysqld
1.2. 还有一种简便的方式设置为开机自启动:
但是可以在在rc.local的尾部加入/usr/bin/mysqld_safe &
2.mysql的多实例启动mysqld_multi
2.1.建立数据存放目录:
Eg :mkdir –p /home/talkyun/data/mysql/data2
mkdir –p /home/talkyun/data/mysql/data3
2.2.使用脚本初始化数据目录:
Mysql_install_db –datadir=/…. –user=mysql
2.3.配置my.cnf文件
[myqld_multi]
mysqld =/opt/mysql5152/bin/mysqld_safe
mysqladmin=/opt/mysql5152/bin/mysqladmin
user =test
password =test
[mysqld3306]
port=3306
socket=/tmp/mysql.sock
basedir=/opt/msyql5152
datadir=/opt/mysql5152/data
[mysqld3307]
port=3307
socket=/tmp/mysql3307.sock
pid-file=/tmp/mysql3307.pid
basedir=/opt/msyql5152
datadir= /home/talkyun/data/mysql/data2
启动:./bin/mysqld_multi --defaults-file=./my.cnf start 3306 3307
连接:mysql -S ./mysql3306.sock
关闭:mysqld_multi --defaults-file=./my.cnf stop 3307
3.mysql启动报 [ERROR] COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8'错误
原因可能是源码编译的是有使用了-DDefault-charset=utf8使得默认的字符集和校验规则不匹配。
在初始化数据库时指定--character-set-server=utf8
并修改my.cnf
[client]
default-character-set=utf8
[mysqld]
character-set-server=utf8
/opt/redmine/mysql/bin/mysqld_safe --defaults-file=/opt/redmine/mysql/my.cnf --port=3306 --socket=/opt/redmine/mysql/tmp/mysql.sock --datadir=/opt/redmine/mysql/data --log-error=/opt/redmine/mysql/data/mysqld.log --pid-file=/opt/redmine/mysql/data/mysqld.pid --lower-case-table-names=1 &
/bin/sh /opt/redmine/mysql/bin/mysqld_safe --defaults-file=/opt/redmine/mysql/my.cnf --port=3306 --socket=/opt/redmine/mysql/tmp/mysql.sock --datadir=/opt/redmine/mysql/data --log-error=/opt/redmine/mysql/data/mysqld.log --pid-file=/opt/redmine/mysql/data/mysqld.pid --lower-case-table-names=1 &
00:48:40 /opt/redmine/mysql/bin/mysqld.bin --defaults-file=/opt/redmine/mysql/my.cnf --basedir=/opt/redmine/mysql --datadir=/opt/redmine/mysql/data --plugin-dir=/opt/redmine/mysql/lib/plugin --user=mysql --lower-case-table-names=1 --log-error=/opt/redmine/mysql/data/mysqld.log --pid-file=/opt/redmine/mysql/data/mysqld.pid --socket=/opt/redmine/mysql/tmp/mysql.sock --port=3306
root 27138 26458 0 18:00 pts/8 00:00:00 grep mysql
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30126478/viewspace-1424195/,如需转载,请注明出处,否则将追究法律责任。