报错1(su进入mysql属组时报错):
[root@dbserver ~]# su - mysql
Last login: Thu Aug 31 17:20:03 CST 2017 on pts/1
su: warning: cannot change directory to /home/mysql: No such file or directory
-bash-4.2$ exit
解决方法:
[root@dbserver ~]# cd /home
[root@dbserver home]# ls
xiniu
[root@dbserver home]# mkdir /home/mysql
[root@dbserver home]# chmod 755 /home/mysql
[root@dbserver home]# ls
mysql xiniu
[root@dbserver home]# cp -a /etc/skel/. /home/mysql/
[root@dbserver home]# su - mysql
Last login: Thu Aug 31 17:20:58 CST 2017 on pts/1
[mysql@dbserver ~]$ id
uid=987(mysql) gid=1003(mysql) 组=1003(mysql) 环境=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
报错2(启动报错):
[root@localhost mysql]# /etc/init.d/mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).
解决方法:
#rm -rf /usr/local/mysql/data
# chown -R mysql.mysql .
# cd /usr/local/mysql
# scripts/mysql_install_db
# /usr/local/mysql/bin/mysqld_safe --user=root &
# ls /usr/local/mysql/data/
# /etc/init.d/mysqld start
Starting MySQL SUCCESS! ##启动成功
报错3(启动报错):
/etc/init.d/mysql: line 256: my_print_defaults: command not found
/etc/init.d/mysql: line 276: cd: /usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
解决办法:
编辑/etc/my.cnf 文件,因为缺少basedir 和 datadir 两个路径,在 [mysqld] 添加上即可
#vim /etc/my.cnf
[mysqld]
...........
...........
basedir=/usr/local/mysql ##修改成自己安装路径
datadir=/usr/local/mysql/data ##修改成自己安装路径
保存退出,然后重新启动就可以.
[root@localhost mysql]# vim /etc/my.cnf
[root@localhost mysql]# service mysql start
Starting MySQL........................................ SUCCESS!