卸载系统自带mariadb 1 2 3 4 5 6 7 [root@iZ2ze3hm3gyjyjz628l7rgZ ~] mariadb-libs-5.5.44-2.el7.centos.x86_64 [root@iZ2ze3hm3gyjyjz628l7rgZ ~] [root@iZ2ze3hm3gyjyjz628l7rgZ ~]
检查MySQL是否存在 1 2 3 [root@iZ2ze3hm3gyjyjz628l7rgZ ~] [root@iZ2ze3hm3gyjyjz628l7rgZ ~]
查看用户和组是否存在 检查mysql组合用户是否存在 1 2 3 [root@iZ2ze3hm3gyjyjz628l7rgZ ~] [root@iZ2ze3hm3gyjyjz628l7rgZ ~]
若不存在,则创建mysql组和用户 1 2 3 4 [root@iZ2ze3hm3gyjyjz628l7rgZ ~] [root@iZ2ze3hm3gyjyjz628l7rgZ ~]
下载MySQL的TAR包 https://dev.mysql.com/downloads/mysql/5.7.html#downloads
上传TAR包到服务器并解压 1 2 3 4 5 6 7 8 9 [root@iZ2ze3hm3gyjyjz628l7rgZ ~] [root@iZ2ze3hm3gyjyjz628l7rgZ src] [root@iZ2ze3hm3gyjyjz628l7rgZ src] [root@iZ2ze3hm3gyjyjz628l7rgZ src] [root@iZ2ze3hm3gyjyjz628l7rgZ local ]
更改所属的组和用户 1 2 3 4 5 6 [root@iZ2ze3hm3gyjyjz628l7rgZ local ] [root@iZ2ze3hm3gyjyjz628l7rgZ local ] [root@iZ2ze3hm3gyjyjz628l7rgZ local ] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql]
在/etc下创建my.cnf文件 1 2 3 4 5 6 [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ etc] [root@iZ2ze3hm3gyjyjz628l7rgZ etc]
my.cnf添加如下内容: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [mysql] default-character-set=utf8 [mysqld] port = 3306 basedir=/usr/local/mysql datadir=/usr/local/mysql/data max_connections=200 character-set-server=utf8 default-storage-engine=INNODB lower_case_table_names=1 max_allowed_packet=16M
查看my.cnf内容 1 2 [root@iZ2ze3hm3gyjyjz628l7rgZ mysql]
进入mysql文件夹,并安装MySQL 1 2 3 4 5 6 7 8 9 [root@iZ2ze3hm3gyjyjz628l7rgZ etc] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] 2018-07-04 15:46:02 [WARNING] 5mysql_install_db is deprecated. Please consider switching to mysqld --initialize 2018-07-04 15:46:05 [WARNING] The bootstrap log isn't empty: 2018-07-04 15:46:05 [WARNING] 2018-07-04T15:46:02.728710Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead 2018-07-01T15:46:02.729161Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2018-07-04 T15:46:02.729167Z 0 [Warning] Changed limits: table_open_cache: 407 (requested 2000)
1 2 3 [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql]
启动MySQL 1 2 3 4 [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] Shutting down MySQL.. Starting MySQL.
设置开机启动 1 2 3 4 5 6 7 8 9 [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] [root@iZ2ze3hm3gyjyjz628l7rgZ mysql] SUCCESS! MySQL running (4475)
修改配置文件 1 2 3 4 5 export PATH=$PATH :/usr/local/mysql/bin[root@iZ2ze3hm3gyjyjz628l7rgZ mysql]
修改MySQL密码 获得MySQL初始密码 1 2 3 [root@iZ2ze3hm3gyjyjz628l7rgZ bin] _pB*3VZl5T<6
修改密码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 [root@iZ2ze3hm3gyjyjz628l7rgZ bin] Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 53 Server version: 5.7.22 MySQL Community Server (GPL) 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> set PASSWORD = PASSWORD('root' ); Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec)
添加远程访问权限 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 mysql> use mysql Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> update user set host='%' where user='root' ; Query OK, 0 rows affected (0.00 sec) Rows matched: 1 Changed: 0 Warnings: 0 mysql> select host,user from user; +-----------+---------------+ | host | user | +-----------+---------------+ | % | root | | localhost | mysql.session | | localhost | mysql.sys | +-----------+---------------+ 3 rows in set (0.00 sec)
重启MySQL生效 1 2 3 4 [root@iZ2ze3hm3gyjyjz628l7rgZ bin] Shutting down MySQL.. Starting MySQL.