mysql安裝和基本配置-redhat

來源:互聯網
上載者:User

標籤: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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.