標籤:tail 檔案 安裝 character root密碼 client china security accept
1.redhat yum替換參考
url:http://blog.csdn.net/zcyhappy1314/article/details/17580943
2.yum卸載mysql
rpm -qa|grep -i mysql
yum remove mysql mysql-server mysql-libs;
或
rpm -ev MySQL-server-4.0.14-0 MySQL-client-4.0.14-0
卸載後/var/lib/mysql中的資料及/etc/my.cnf不會刪除,如果確定沒用後就手工刪除
rm -f /etc/my.cnf
rm -rf /var/lib/mysql
3.yum 安裝mysql
[root@sample ~]# yum -y install mysql-server ← 安裝MySQL
參考 url:http://evanlinux.blog.51cto.com/7247558/1374023
4.配置MySQL
[root@sample ~]#vim /etc/my.cnf ← 編輯MySQL的設定檔
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
old_passwords=1
default-character-set=utf8 ← 添加這一行
5.查看連接埠3306
lsof -i:3306
6.防火牆開放連接埠3306
vim /etc/sysconfig/iptables
增加一行
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
使其生效
service iptables restart
/etc/rc.d/init.d/iptables save
7.啟動mysql
[[email protected] ~]#/etc/rc.d/init.d/mysqld start ← 啟動MySQL服務
或者
[[email protected] ~]# service mysqld start
8.允許mysql外網訪問
use mysql;
select host,user from user;
update user set host=‘%‘ where user=‘root‘ and host=‘localhost‘;
flush privileges;
這個時候就可以使用圖形管理工具訪問了。。。。
9.之後可能會遇到這個錯誤
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)
做如下操作:
service mysqld stop
mysqld_safe --skip-grant-tables --skip-networking &
use mysql;
select host,user,password from user;
delete from user where host!=‘%‘
10.設定root密碼
MySQL在剛剛被安裝的時候,它的root使用者是沒有被設定密碼的。首先來設定MySQL的root密碼。
[[email protected] ~]# mysql -u root ← 用root使用者登入MySQL伺服器
mysql> UPDATE user SET Password=PASSWORD(‘963852‘) where USER=‘root‘ and host=‘%‘;
或
mysql>grant all on mysql.* to ‘root‘@‘localhost‘ identified by ‘password‘;
或
mysql> set password for ‘root‘@‘localhost‘ =password(‘123456‘);
之後 就可以通過密碼登入mysql了。
11.使用權限設定
任意主機以使用者root和密碼mypwd串連到mysql伺服器,擁有所有資料庫的所有表進行所有操作的許可權
mysql> GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘963852‘ WITH GRANT OPTION;
mysql> flush privileges;
mysql安裝和基本配置-redhat