附上官方教程地址:
https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
下面是/etc/my.cnf文件 以后用到的以后再网上添加 (最好先把配置文件改好,再实例化mysql)
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
user = mysql
port = 3306
socket = /tmp/mysql.sock
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file =/usr/local/mysql/data/mysql.pid
character-set-server=utf8
错误解决:
ERROR 2002: Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (111)
出现这个错误,使用以下启动mysql的命令试下
/usr/local/mysql/bin/mysql -u root -p
/usr/local/mysql/bin/mysqld --user=mysql& (我碰到这个错误,使用这条命令启动成功的)
/usr/local/mysql/bin/mysqld --user=root&
/usr/local/mysql/bin/mysqld_safe --user=root&
/usr/local/mysql/bin/mysqld_safe --user=mysql&
/usr/local/mysql/bin/safe_mysqld--uer=root&(注意safe_mysqld与mysqld_safe是不同的,&表示mysql在后台运行)