7、mysql的配置和安裝
阿新 • • 發佈:2018-03-24
tail 創建 san ext 註意 重新 ica data value
來自為知筆記(Wiz)
- 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 mmall@‘%‘ identified by ‘mmall‘ with grant option;
- 註意,此語句可能有錯誤,導致執行下面的權限查詢的時候出現授權不起作用的現象,可以改為下面的授權語句。
- grant all privileges on *.* to mmall@‘%‘ identified by ‘mmall‘ with grant option;
- 請參看
- https://bbs.csdn.net/topics/330154879
- 可以更細化權限為
- grant select,delete,create on mmall.* to mmall@‘%‘ identified by ‘mmall‘ with grant option;
- 重新查看全新
- select * from mysql.user \G
- 修改root賬號的密碼
- set password for root@localhost=password(‘root‘);
- set password for [email protected]=password(‘root‘);
- select user,host,password from mysql.user;
- 退出重新登錄
- 使用密碼登錄,否則沒有權限
- win下安裝mysql
- 略
來自為知筆記(Wiz)
7、mysql的配置和安裝