安装
推荐使用官方编译好的包进行安装,通常我们安装到/usr/local目录下面,这样做的好处是后期
维护很方便。安装步骤如下:
shell> groupadd mysql
shell> useradd -r -g mysql -s /bin/false mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> mkdir mysql-files
shell> chown mysql:mysql mysql-files
shell> chmod 750 mysql-files
shell> bin/mysqld --initialize --user=mysql
shell> bin/mysql_ssl_rsa_setup
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server
https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
Login errors
Erro1
当我第一次登陆时:
mysql -u mysql -p
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Erro2
加上host再登陆时:
mysql -h 127.0.0.1 -u mysql -p
ERROR 1045 (28000): Access denied for user 'mysql'@'localhost' (using password: YES)
用root用户登录
mysql -h 127.0.0.1 -u root -p
#type your temp password
mysql> set password="123";