環境 CentOS
yum install -y mysql-server mysql mysql-deve
service啟動
service mysqld start
service mysqld restart
service mysqld stop
查看進程
ps aux |grep mysql
殺死進程
kill -9 xx
cd /usr/local/mysql/bin/
啟動命令:
./mysqld_safe --user=mysql &
查看啟動狀態
netstat -ntlp |grep mysql
yum remove mysql mysql-server mysql-libs compat-mysql51
rm -rf /var/lib/mysql
rm /etc/my.cnf
查看是否還有mysql軟件:
rpm -qa|grep mysql
有的話繼續刪除
mysql -u root –p 然後輸入密碼即可
退出: exit
查看系統用戶
vi /etc/mysql/debian.cnf
mysql -h[host] -u[user] -p[password] -P[port] -D[dbName]
mysql -h192.168.1.225 -utest -ptest -P8066 –Ddbtest
1) 運行命令: netstat -an | grep [mysqlport] 查看mysql運行端口的ip限制
如果是localhost,說明mysql綁定了訪問ip,要進行修改
vi /etc/mysql/my.cnf
將[mysqld]下面的(vi 編輯器使用參考《linux操作手冊》)
bind-address = 127.0.0.1 注釋掉即可
重啟mysql
2) 用root登錄mysql執行
use mysql
select user,host from user;
顯示結果如下:
+------------------+---------------+
| user | host |
+------------------+---------------+
| debian-sys-maint | localhost |
| root | localhost |
+------------------+---------------+
表面只有localhost才能訪問
執行如下語句:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'bruce' WITH GRANT OPTION;
select user,host from user;
顯示結果如下:
+------------------+-----------+
| user | host |
+------------------+-----------+
| root | % |
| debian-sys-maint | localhost |
| root | localhost |
+------------------+-----------+
至此遠程訪問mysql的問題解決了
vi /etc/mysql/my.cnf
[mysqld] 下添加
lower_case_table_names=1
必須在建表之前設置
參考:http://blog.163.com/zjc_8886/blog/static/240817520117111562089/
vi /etc/mysql/my.cnf
在[client]下增加
default-character-set=utf8
[mysqld]下增加
character_set_server=utf8
[mysql]下增加
character_set_server=utf8
查看和修改數據庫最大連接
查看數據庫最大連接
show VARIABLES like '%connection%'
ubuntu:
vi /etc/mysql/my.cnf
centos:
vi /etc/my.cnf
添加
max_connections = 200
重啟mysql
查看運行進程數
show processlist