close
文章出處

安裝

#yum源
http://dev.mysql.com/downloads/repo/yum/
#安裝
rpm -Uvh
http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
yum install mysql-community-server
#啟動服務
service mysqld start
#登錄mysql
mysql -u root -p
# mysql5.7安裝完成后會初始化一個root用戶的默認密碼
grep 'temporary password' /var/log/mysqld.log
2016-03-20T10:13:53.378957Z 1 [Note] A temporary password is generated for root@localhost: Ad2onLig55=l
#啟動MySQL服務
service mysqld start
#執行MySQL的安全配置向導
[root@iZ11fek1j6cZ log]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.

- Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done!

修改編碼

vi /etc/my.cnf

[client]
default-character-set = utf8

[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci

#重啟MySQL服務
service mysqld restart

#檢查編碼
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor...
...
mysql> show variables like '%char%';
+--------------------------------------+----------------------------+
| Variable_name                        | Value                      |
+--------------------------------------+----------------------------+
| character_set_client                 | utf8                       |
| character_set_connection             | utf8                       |
| character_set_database               | utf8                       |
| character_set_filesystem             | binary                     |
| character_set_results                | utf8                       |
| character_set_server                 | utf8                       |
| character_set_system                 | utf8                       |
| character_sets_dir                   | /usr/share/mysql/charsets/ |
| validate_password_special_char_count | 1                          |
+--------------------------------------+----------------------------+
9 rows in set (0.00 sec)

mysql>

#開啟自動啟動服務
chkconfig mysqld on
#檢查服務
chkconfig --list | grep mysql

卸載

#是否已經安裝了mysql數據庫
rpm -qa | grep mysql
#普通刪除模式
rpm -e mysql
#強力刪除模式
rpm -e --nodeps mysql
#是否已經卸載成功
rpm -qa | grep mysql

問題

ERROR 1130: Host 'xxx' is not allowed to connect to this MySQL server

解決方法:

1。 改表法。可能是你的帳號不允許從遠程登陸,只能在localhost。這個時候只要在localhost的那臺電腦,登入mysql后,更改 "mysql" 數據庫里的 "user" 表里的 "host" 項,從"localhost"改稱"%"

use mysql;
mysql>update user set host = '%' where user = 'root';
mysql>select host, user from user;

REFER:
centos很正規的使用yum安裝mysql5.7小白鼠版
http://www.hishenyi.com/archives/808
如果mysql中某sql執行慢,怎么記錄下來
http://www.hishenyi.com/archives/763


不含病毒。www.avast.com
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 AutoPoster 的頭像
    AutoPoster

    互聯網 - 大數據

    AutoPoster 發表在 痞客邦 留言(0) 人氣()