標籤:style blog http color os io 使用 ar strong
安裝查看有沒有安裝過:
yum list installed mysql*
rpm -qa | grep mysql*
查看有沒有安裝包:
yum list mysql*
安裝mysqlclient:
yum install mysql
安裝mysql server端:
yum install mysql-server
yum install mysql-devel
啟動&&停止資料庫字元集設定
mysql設定檔/etc/my.cnf中的[mysqld]配置節中添?default-character-set=utf8
有時候設定檔可能在/usr/my.cnf中,假設還是找不到,使用下面命令尋找:
find -name my.cnf
方法:vi /etc/my.cnf,通過上下左右鍵移動游標,按字母“i”進入編輯狀態,Shift + Insert 粘貼內容(我是通過Xshell操作的),按ESC鍵進入命令模式,輸入“:wq”按斷行符號鍵。
啟動mysql服務:
service mysqld start或者/etc/init.d/mysqld start
開機啟動:
chkconfig -add mysqld,查看開機啟動設定是否成功chkconfig --list | grep mysql*
mysqld 0:關閉 1:關閉 2:啟用 3:啟用 4:啟用 5:啟用 6:關閉
停止:
service mysqld stop
登入建立root管理員:
mysqladmin -u root password 123456
這個沒有運行通過,提示:mysqladmin: Can‘t turn off logging; error: ‘Access denied; you need the SUPER privilege for this operation‘
登入:
mysql -u root -p輸入密碼就可以。
忘記密碼:
service mysqld stop
mysqld_safe --user=root --skip-grant-tables
運行這條語句之後就不能再輸入命令了,
輸出:140616 19:23:09 mysqld_safe Logging to ‘/var/log/mysqld.log‘.
140616 19:23:09 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
之後就停在那裡不動,須要再開終端運行命令;
mysql -u root
use mysql;
update user set password=password(’123456‘) where user=’root‘;
flush privileges;
可是運行完這些命令沒能解決Windows下使用Navicat for MySql串連不上的問題;
遠程訪問開放防火牆的port號,或關閉防火牆;
mysql添加?許可權:mysql庫中的user表新增一條記錄host為“%”,user為“root”。
這個測試也無論用;
Linux MySQL的幾個關鍵檔案夾資料庫檔案夾
/var/lib/mysql/
設定檔
/usr/share /mysql(mysql.server命令及設定檔)
相關命令
/usr/bin(mysqladmin mysqldump等命令)
啟動指令碼
/etc/rc.d/init.d/(啟動指令檔mysql的檔案夾)
Windows下使用Navicat for MySql串連
錯誤:1130 host is not allowed to connect to this mysql server
解決方案:
1。 改表法。
可能是你的帳號不同意從遠程登陸,僅僅能在localhost。這個時候僅僅要在localhost的那台電腦,登入mysql後,更改 "mysql" 資料庫裡的 "user" 表裡的 "host" 項,從"localhost"改稱"%"
mysql -u root -pvmwaremysql>use mysql;
mysql>update user set host = ‘%‘ where user = ‘root‘;
mysql>select host, user from user;
2. 授權法。
比如,你想myuser使用mypassword從不論什麼主機串連到mysqlserver的話。
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘%‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
這個測試通過,只是記得改動語句中的“myuser”和“mypassword”,我就是拿過來直接就運行了,結果搞了半天才發現。
假設你想同意使用者myuser從ip為192.168.1.6的主機串連到mysqlserver,並使用mypassword作為密碼
GRANT ALL PRIVILEGES ON *.* TO ‘myuser‘@‘192.168.1.3‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
假設你想同意使用者myuser從ip為192.168.1.6的主機串連到mysqlserver的dk資料庫,並使用mypassword作為密碼
GRANT ALL PRIVILEGES ON dk.* TO ‘myuser‘@‘192.168.1.3‘ IDENTIFIED BY ‘mypassword‘ WITH GRANT OPTION;
FLUSH PRIVILEGES;
在安裝mysql的機器上運行:
1、d:\mysql\bin\>mysql -h localhost -u root //這樣應該能夠進入MySQLserver
2、mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ WITH GRANT OPTION //賦予不論什麼主機訪問資料的許可權
3、mysql>FLUSH PRIVILEGES //改動生效
4、mysql>EXIT //退出MySQLserver
這樣就能夠在其他不論什麼的主機上以root身份登入啦!
CentOS下安裝MySQL,Windows下使用Navicat for MySql串連