標籤:自動啟動 檔案 collate put yum soft utf8 匿名使用者 rest
- linux環境下mysql的安裝
- sudo yum install mysql-server
- 修改設定檔
- vim /etc/my.cnf
- 添加default-character-set = utf8
- 設定mysql隨系統自動啟動
-
- 檢查設定是否正確
- sudo chkconfig --list mysqld
- mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
- 2-5都是啟動則ok
- 啟動mysql
- sudo service mysqld start
- 如果出現錯誤 MySQL Daemon failed to start. 請參考
- http://blog.csdn.net/u012286517/article/details/50436740
- 刪除匿名使用者
- select user,host from mysql.user;
- +------+--------------------+
- | user | host |
- +------+--------------------+
- | root | 127.0.0.1 |
- | | localhost |
- | root | localhost |
- | | vm\_24\_26\_centos |
- | root | vm\_24\_26\_centos |
- +------+--------------------+
- delete from mysql.user where user=‘‘;
- 重新整理一下許可權
- flush privileges;
- 在防火牆下面開放3306連接埠,開放給外網
- sudo vim /etc/sysconfig/iptables
- #mysql port
- -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
- 重啟防火牆
- service iptables restart
- 重新登入mysql
- mysql -u root
- 建立一個非root許可權的賬戶,避免使用root
- insert into mysql.user(Host,User,Password)values("localhost","mmall",password("mmall"));
- 檢查插入是否正確
- select user,host from mysql.user;
- +-------+--------------------+
- | user | host |
- +-------+--------------------+
- | root | 127.0.0.1 |
- | mmall | localhost |
- | root | localhost |
- | root | vm\_24\_26\_centos |
- +-------+--------------------+
- 建立一個資料庫
- create database `mmall` default character set utf8 collate utf8_general_ci;
- 查看許可權
- select * from mysql.user \G
- 賦予許可權
- 切換資料庫 use mmall;
- grant all privileges on mmall.* to [email protected]‘%‘ identified by ‘mmall‘ with grant option;
- 注意,此語句可能有錯誤,導致執行下面的許可權查詢的時候出現授權不起作用的現象,可以改為下面的授權語句。
- grant all privileges on *.* to [email protected]‘%‘ identified by ‘mmall‘ with grant option;
- 請參看
- https://bbs.csdn.net/topics/330154879
- 可以更微調權限為
- grant select,delete,create on mmall.* to [email protected]‘%‘ identified by ‘mmall‘ with grant option;
- 重新查看全新
-
- select * from mysql.user \G
- 修改root帳號的密碼
- set password for [email protected]=password(‘root‘);
- set password for [email protected]=password(‘root‘);
- select user,host,password from mysql.user;
- 退出重新登入
- 使用密碼登入,否則沒有許可權
- win下安裝mysql
- 略
來自為知筆記(Wiz)
7、mysql的配置和安裝