First, uninstall MARIADB
[Email protected] ~]# rpm-qa mariadb*mariadb-libs-5.5. 2-e--nodeps mariadb-libs-5.5. -2-qa | grep mariadb
System environment:
[Email protected] ~]# cat/etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[Email protected] ~]# uname-r
3.10.0-327.el7.x86_64
Second, compile and install MySQL
#安装依赖包
#文件目录创建
Mkdir-p/home/nulige/mysql/3306/-p/home/nulige/mysql/3306/-p/home/nulige/ mysql/3306/log
#创建用户组和mysql用户
-s/sbin/nologin-g MySQL-M mysqlid MySQL
#创建软件目录
Mkdir-p/home/nulige/
#下载软件
wget http://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gzwget HTTPS ://osdn.net/frs/g_redir.php?m=netix&f=%2flonenmp%2flnmpfiles%2fmysql%2fmysql-5.7.11.tar.gz
# UTF8MB4 Format Explained
MySQL added this utf8mb4 code after 5.5.3, Mb4 is the most bytes 4 meaning, specifically designed to be compatible with four-byte Unicode. Fortunately, UTF8MB4 is a superset of UTF8, except that there is no need to convert the encoding to UTF8MB4. Of course, in order to save space, the general use of UTF8 is enough.
As for when to use, see what you do to the project.
When you do a mobile app, you'll encounter an iOS user entering a emoji expression in the text area that will cause the database exception to be inserted if you don't do some processing.
#解压安装
tar xzf boost_1_59_0.tar.gztar xzf MySQL-5.7. One. TAR.GZCD MySQL-5.7. OneCMake-dcmake_install_prefix=/home/nulige/mysql/3306 -dmysql_datadir=/home/nulige/mysql/3306/Data-dwith_boost=/home/nulige/mysql/Boost_1_59_0-dsysconfdir=/home/nulige/MySQL-dwith_innobase_storage_engine=1 -dwith_partition_storage_engine=1 -dwith_federated_storage_engine=1 -dwith_blackhole_storage_engine=1 -dwith_myisam_storage_engine=1 -denabled_local_infile=1 -denable_dtrace=0 -ddefault_charset= utf8mb4 -ddefault_collation=Utf8mb4_general_ci-dwith_embedded_server=1
#编译安装make && make install
#配置启动服务/bin/cp/home/nulige/mysql/3306/support-files/mysql.server/etc/init.d/Mysqldchmod+x/etc/init.d/Mysqldchkconfig--add mysqldchkconfig mysqld on#/etc/my.cnf, for reference only (for production also need tuning) [Mysqld]basedir=/home/nulige/mysql/3306DataDir=/home/nulige/mysql/3306/Datatmpdir=/home/nulige/mysql/3306/Tmppid-file =/home/nulige/mysql/3306/data/My.pidport=3306Default_storage_engine=Innodbinnodb_autoinc_lock_mode=2Explicit_defaults_for_timestamp=truecharacter-Set-client-handshake =Falsecharacter_set_server=Utf8skip-name-resolvemax_connect_errors=1000000Max_allowed_packet=1gconnect_timeout=3600Wait_timeout=3600Interactive_timeout=3600Innodb_lock_wait_timeout=Tenslave-skip-errors =1032,1062Log-error =/home/nulige/mysql/3306/log/Error.logslow_query_log=Onslow_query_log_file=/home/nulige/mysql/3306/log/slow-query-Log.loglong_query_time=1Log-queries-not-using-Indexeslog-slow-admin-Statementslog-slow-slave-Statementsserver-id = -Log-bin = log-Binbinlog-format = ROW
#初始化数据库
Chown-r mysql:mysql/home/nulige/mysql/3306/CD/home/nulige/mysql/3306/bin./mysql_install_db--user=mysql--basedir=/home/nulige/mysql/3306--datadir=/home/nulige/mysql/3306/Data Note: A warning will be reported here, directly ignoring .- to- + -: -: -[WARNING] mysql_install_db isDeprecated. Consider switching to mysqld--Initialize meaning: Before version mysql_install_db was in Mysql_basedirUnder the/script,5.7 put it in the mysql_install_db/.Bin directory, and has been deprecated"--initialize"Generates a random password (~/.mysql_secret), and"--initialize-insecure"No password is generated and no data files can be--datadir the target directory.
#启动 Database
Service mysqld Start
#设置开机自启动
[[Email protected] ~ is not a native service, redirecting to/sbin//sbin/chkconfig mysqld on
#查看端口
3306 TCP LISTEN 0::: 3306 :::* Users: (("mysqld ", pid=25042, fd=))
#配置环境变量
' path=/home/nulige/mysql/3306/bin/: $PATH ' >>/etc//etc/profileecho $PATH
#查看mysql默认密码
[Email protected] bin]# cat/root/setfor'[email protected]' ---: ayjdul! 3-;*
#用默认密码, log in to the database
Mysql-uroot-p': ayjdul!3-;*' #这边密码要加引号, or if there is an escape problem
#修改密码 (This password must be complex enough, or will not let you change, the password is not valid)
' Root '@'localhost' = PASSWORD ('[email protected]'); MySQL> flush privileges; MySQL> exitbye
#登录数据库
[Email protected] bin]# mysql-uroot-p'[email protected]'
8. View MySQL Version
[email protected] bin]# mysql- vmysql14.145.7. one forusing editline Wrapper
9. View Database User table
Select from Mysql.user; +-----------+-----------+| Host | user |+-----------+-----------+| localhost | mysql.sys | | localhost | root |+-----------+------- ----+2inset (0.00 sec)
mysql5.7.x Compiling and installing