linux 安裝mysql數據庫
附上官方教程地址:
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在後臺運行)
linux 安裝mysql數據庫