卸載自帶MariaDB
[root@root tmp]# rpm -qa | grep mariadb
mariadb-libs-5.5.41-2.el7_0.x86_64
[root@root tmp]# rpm -e --nodeps mariadb-libs-5.5.41-2.el7_0.x86_64
下載安裝包
安裝
// 下載
[root@root tmp]# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar
--2018-05-03 09:53:46-- https://dev.mysql.com/get/Downloads/MySQL-5.6/MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar
正在解析主機(jī) dev.mysql.com (dev.mysql.com)... 137.254.60.11
正在連接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:443... 已連接牵啦。
已發(fā)出 HTTP 請(qǐng)求,正在等待回應(yīng)... 302 Found
位置:https://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar [跟隨至新的 URL]
--2018-05-03 09:53:47-- https://cdn.mysql.com//Downloads/MySQL-5.6/MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar
正在解析主機(jī) cdn.mysql.com (cdn.mysql.com)... 23.11.255.146
正在連接 cdn.mysql.com (cdn.mysql.com)|23.11.255.146|:443... 已連接摊腋。
已發(fā)出 HTTP 請(qǐng)求沸版,正在等待回應(yīng)... 200 OK
長度:243456000 (232M) [application/x-tar]
正在保存至: “MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar”
100%[===========================================================================================================================================================>] 243,456,000 6.10MB/s 用時(shí) 41s
2018-05-03 09:54:29 (5.68 MB/s) - 已保存 “MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar” [243456000/243456000])
// 解壓
[root@root tmp]# tar -xvf MySQL-5.6.40-1.el7.x86_64.rpm-bundle.tar
MySQL-shared-5.6.40-1.el7.x86_64.rpm
MySQL-devel-5.6.40-1.el7.x86_64.rpm
MySQL-server-5.6.40-1.el7.x86_64.rpm
MySQL-shared-compat-5.6.40-1.el7.x86_64.rpm
MySQL-test-5.6.40-1.el7.x86_64.rpm
MySQL-client-5.6.40-1.el7.x86_64.rpm
MySQL-embedded-5.6.40-1.el7.x86_64.rpm
// 安裝,跳過此步操作兴蒸,請(qǐng)先進(jìn)行下一步操作视粮,會(huì)出錯(cuò)
[root@root tmp]# rpm -ivh MySQL-server-5.6.40-1.el7.x86_64.rpm
出現(xiàn)錯(cuò)誤:
警告:MySQL-server-5.6.40-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 密鑰 ID 5072e1f5: NOKEY
準(zhǔn)備中... ################################# [100%]
正在升級(jí)/安裝...
1:MySQL-server-5.6.40-1.el7 ################################# [100%]
警告:用戶mysql 不存在 - 使用root
警告:群組mysql 不存在 - 使用root
警告:用戶mysql 不存在 - 使用root
警告:群組mysql 不存在 - 使用root
FATAL ERROR: please install the following Perl modules before executing /usr/bin/mysql_install_db:
Data::Dumper
解決方案:
// 安裝組件
[root@root tmp]# yum install -y perl-Module-Install.noarch
// 卸載原有的,重新安裝
[root@root tmp]# rpm -qa | grep -i mysql
MySQL-server-5.6.40-1.el7.x86_64
[root@root tmp]# rpm -e MySQL-server-5.6.40-1.el7.x86_64
警告:MySQL-server-5.6.40-1.el7.x86_64.rpm: 頭V3 DSA/SHA1 Signature, 密鑰 ID 5072e1f5: NOKEY
準(zhǔn)備中... ################################# [100%]
正在升級(jí)/安裝...
1:MySQL-server-5.6.40-1.el7 ################################# [100%]
警告:用戶mysql 不存在 - 使用root
警告:群組mysql 不存在 - 使用root
警告:用戶mysql 不存在 - 使用root
警告:群組mysql 不存在 - 使用root
2018-05-03 10:26:04 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-03 10:26:04 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-05-03 10:26:04 0 [Note] /usr/sbin/mysqld (mysqld 5.6.40) starting as process 2589 ...
2018-05-03 10:26:04 2589 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-05-03 10:26:04 2589 [Note] InnoDB: The InnoDB memory heap is disabled
2018-05-03 10:26:04 2589 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-03 10:26:04 2589 [Note] InnoDB: Memory barrier is not used
2018-05-03 10:26:04 2589 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-03 10:26:04 2589 [Note] InnoDB: Using Linux native AIO
2018-05-03 10:26:04 2589 [Note] InnoDB: Using CPU crc32 instructions
2018-05-03 10:26:04 2589 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-05-03 10:26:04 2589 [Note] InnoDB: Completed initialization of buffer pool
2018-05-03 10:26:04 2589 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2018-05-03 10:26:04 2589 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2018-05-03 10:26:04 2589 [Note] InnoDB: Database physically writes the file full: wait...
2018-05-03 10:26:04 2589 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2018-05-03 10:26:05 2589 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2018-05-03 10:26:06 2589 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2018-05-03 10:26:06 2589 [Warning] InnoDB: New log files created, LSN=45781
2018-05-03 10:26:06 2589 [Note] InnoDB: Doublewrite buffer not found: creating new
2018-05-03 10:26:06 2589 [Note] InnoDB: Doublewrite buffer created
2018-05-03 10:26:06 2589 [Note] InnoDB: 128 rollback segment(s) are active.
2018-05-03 10:26:06 2589 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-05-03 10:26:06 2589 [Note] InnoDB: Foreign key constraint system tables created
2018-05-03 10:26:06 2589 [Note] InnoDB: Creating tablespace and datafile system tables.
2018-05-03 10:26:06 2589 [Note] InnoDB: Tablespace and datafile system tables created.
2018-05-03 10:26:06 2589 [Note] InnoDB: Waiting for purge to start
2018-05-03 10:26:06 2589 [Note] InnoDB: 5.6.40 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2018-05-03 10:26:06 2589 [Note] Binlog end
2018-05-03 10:26:06 2589 [Note] InnoDB: FTS optimize thread exiting.
2018-05-03 10:26:06 2589 [Note] InnoDB: Starting shutdown...
2018-05-03 10:26:08 2589 [Note] InnoDB: Shutdown completed; log sequence number 1625977
2018-05-03 10:26:08 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-05-03 10:26:08 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2018-05-03 10:26:08 0 [Note] /usr/sbin/mysqld (mysqld 5.6.40) starting as process 2611 ...
2018-05-03 10:26:08 2611 [Note] InnoDB: Using atomics to ref count buffer pool pages
2018-05-03 10:26:08 2611 [Note] InnoDB: The InnoDB memory heap is disabled
2018-05-03 10:26:08 2611 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-05-03 10:26:08 2611 [Note] InnoDB: Memory barrier is not used
2018-05-03 10:26:08 2611 [Note] InnoDB: Compressed tables use zlib 1.2.3
2018-05-03 10:26:08 2611 [Note] InnoDB: Using Linux native AIO
2018-05-03 10:26:08 2611 [Note] InnoDB: Using CPU crc32 instructions
2018-05-03 10:26:08 2611 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-05-03 10:26:08 2611 [Note] InnoDB: Completed initialization of buffer pool
2018-05-03 10:26:08 2611 [Note] InnoDB: Highest supported file format is Barracuda.
2018-05-03 10:26:08 2611 [Note] InnoDB: 128 rollback segment(s) are active.
2018-05-03 10:26:08 2611 [Note] InnoDB: Waiting for purge to start
2018-05-03 10:26:08 2611 [Note] InnoDB: 5.6.40 started; log sequence number 1625977
2018-05-03 10:26:08 2611 [Note] Binlog end
2018-05-03 10:26:08 2611 [Note] InnoDB: FTS optimize thread exiting.
2018-05-03 10:26:08 2611 [Note] InnoDB: Starting shutdown...
2018-05-03 10:26:10 2611 [Note] InnoDB: Shutdown completed; log sequence number 1625987
A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
// 密碼存放處
You will find that password in '/root/.mysql_secret'.
You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.
Also, the account for the anonymous user has been removed.
In addition, you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test database.
This is strongly recommended for production servers.
See the manual for more instructions.
Please report any problems at http://bugs.mysql.com/
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
[root@root tmp]# rpm -ivh MySQL-server-5.6.40-1.el7.x86_64.rpm
// 安裝客戶端
[root@root tmp]# rpm -ivh MySQL-client-5.6.40-1.el7.x86_64.rpm
// 安裝開發(fā)環(huán)境
[root@root tmp]# rpm -ivh MySQL-devel-5.6.40-1.el7.x86_64.rpm
修改密碼
使用此種RPM安裝方式橙凳,直接查看
/root/.mysql_secret
獲取初始密碼蕾殴,再進(jìn)行修改
[root@root tmp]# vim /root/.mysql_secret
# The random password set for the root user at Thu May 3 10:26:06 2018 (local time): PP5AHQi1LgirSWnu
[root@root tmp]# mysql -uroot -pPP5AHQi1LgirSWnu
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
[root@rabbit3 tmp]# systemctl restart mysql
[root@rabbit3 tmp]# mysql -uroot -pPP5AHQi1LgirSWnu
Warning: Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.40
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
// 修改密碼
mysql> SET PASSWORD = PASSWORD('123456');
配置遠(yuǎn)程可登錄
- 授權(quán)法
mysql> grant all privileges on *.* to root@'%' identified by "123456";
// 推送設(shè)置到內(nèi)存或重啟服務(wù)器也行
mysql> FLUSH PRIVILEGES;