1.解压压缩包
tar -zvxf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
2.添加用户,不让登陆,更严格点的,可以用/bin/false
useradd mysql -r -s /sbin/nologin
3.创建目录
mkdir /usr/local/mysql
4。把解压的文件移动到刚刚建的路径下面
mv * /usr/local/mysql/
5.修改所有者
chown -R mysql:mysql /usr/local/mysql
6.删掉centos7自带的文件
rm -rf /etc/my.cnf
7.安装缺少的依赖包
yum -y install autoconf
yum install libaio* -y
8.初始化数据库
scripts/mysql_install_db --user=mysql
9.copy启动脚本
cp support-files/mysql.server /etc/init.d/mysql35
10.开始启动
service mysql35 start
后续的配置
root@iZbp143t3oxhfc3ar7jey0Z bin]# mysqladmin -u root password 123456./ Warning: Using a password on the command line interface can be insecure. [root@iZbp143t3oxhfc3ar7jey0Z bin]# hostname iZbp143t3oxhfc3ar7jey0Z [root@iZbp143t3oxhfc3ar7jey0Z bin]# hostname./mysqladmin -u root password 123456-h iZbp password 123456 1 password 123456 64 password 1234563 password 123456t password 1234563 password 123456o password 123456x password 123456h password 123456f password 123456c passwor3 passwoa passwr pass7 pasj pae p y0Z Warning: Using a password on the command line interface can be insecure. [root@iZbp143t3oxhfc3ar7jey0Z bin]# cat /etc/hosts ::1localhostlocalhost.localdomainlocalhost6localhost6.localdomain6 127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4 172.16.123.216iZbp143t3oxhfc3ar7jey0ZiZbp143t3oxhfc3ar7jey0Z [root@iZbp143t3oxhfc3ar7jey0Z mysql]# ./bin/muysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MySQL to secure it, we'll need the current password for the root user. If you've just installed MySQL, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] 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? [Y/n] 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? [Y/n] y^H^[[3~ 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? [Y/n] 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? [Y/n] y ... Success! All done! If you've completed all of the above steps, your MySQL installation should now be secure. Thanks for using MySQL! Cleaning up...
在/etc/profile下,添加mysql,就能找到mysql的目录了
[root@iZbp143t3oxhfc3ar7jey0Z ~]# mysql -bash: mysql: command not found [root@iZbp143t3oxhfc3ar7jey0Z ~]# source /etc/profile [root@iZbp143t3oxhfc3ar7jey0Z ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 12 Server version: 5.6.35 MySQL Community Server (GPL) Copyright (c) 2000, 2016, 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> 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'; ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY'