vim /etc/profile
# 在文件最后增加:
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH
修改端口號
# 登錄查詢端口號
mysql -u root -p
show global variables like 'port'
vim /etc/my.cnf
# 編輯內(nèi)容如下
[mysqld]
port=7888
datadir=/usr/local/mysql/data
user=mysql
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
# 保存后重啟服務(wù):
service mysqld restart
修改字符編碼
show variables like 'character%';
# 如果出現(xiàn)latin1榕暇,則我們需要統(tǒng)計(jì)編碼方式
[mysqld]
# 增加一行
character_set_server=utf8
# 重啟
/etc/init.d/mysqld restart
遠(yuǎn)程訪問設(shè)置
# 本地root用戶登錄mysql, 與本地的root賬戶并不沖突
grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
# 如果設(shè)置了防火墻
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 7888 -j ACCEPT
iptables -L -n
# 限制訪問
iptables -D INPUT -p tcp -m state --state NEW -m tcp --dport 7888 -j ACCEPT