1. Preparation prior to installation
Uninstall the mariadb Centos7 comes with
rpm -qa|grep mariadb #查看一下是否有mariadb相关的包rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64 #把查询到的包卸载
- Download the MySQL installation package
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.60.tar.gz
- Download CMake installation package
wget https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz
- Adding MySQL Users and Groups
groupadd mysqluseradd mysql -s /sbin/nologin -M -g mysql # -s /sbin/nologin 表示禁止该用户登录,加强安全; -g mysql 指定属于mysql组; -M 表示不创建用户家目录
- Installing Ncurses-devel
yum install ncurses-devel -y
- Installing CMake
tar zxvf cmake-3.10.2.tar.gz -C /usr/localcd /usr/local/cmake-3.10.2./configuregmake && gmake install
2. Installing MYQSL
tar zxvf mysql-5.5.60.tar.gzcd mysql-5.5.60cmake.-dcmake_install_prefix=/application/mysql-5.5.60- Dmysql_datadir=/application/mysql-5.5.60/data-dmysql_unix_addr=/application/mysql-5.5.60/mysql.sock-ddefault_ Charset=utf8-ddefault_collation=utf8_general_ci-denabled_local_infile=on-dwith_innobase_storage_engine=1-dwith _federated_storage_engine=1-dwith_blackhole_storage_engine=1-dwithout_example_storage_engine=1-dwith_fast_ mutexes=1-dwith_zlib=bundled-denabled_local_infile=1-dwith_readline=1-dwith_embedded_server=1-dwith_debug= 0make && make install
-
Do a soft connection
ln-s/application/mysql-5.5.60//application/mysql
-
MySQL Directory authorization
chown-r mysql:mysql/application/mysql-5.5.60/
-
Copy related files
CD/APPLICATION/MYSQL/SUPPORT-FILESCP MY-SMALL.CNF/ETC/MY.CNFCP mysql.server/etc/init.d/mysqldchmod +x/etc/ Init.d/mysqld
- mysql init
cd/application/mysql/scripts/./mysql_install_db--basedir =/application/mysql/--datadir=/application/mysql/data/--user=mysql
- start MySQL
etc /init.d/mysqld start
- Configure environment Variables
echo ' export path=/application/mysql/bin: $PATH ' > >/etc/profilesource/etc/profile
- Configure login password
/application/mysql//bin/mysqladmin-u Root password ' zacs164.com '
-
Set MySQL boot up
chkconfig mysqld onchkconfig--list Mysqld #查看一下
- login MySQL
Normal situation can be logged in normally, but I logged in when the following error message:
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
Workaround:
- 1. Stop MySQL Database
/etc/init.d/mysqld stop
- 2. Execute the following command
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
- 3. Log in to the MySQL database using root
mysql -u root mysql
- 4. Update the root password
UPDATE user SET Password=PASSWORD(‘ZACS164.COM‘) where USER=‘root‘;
- 5. Refresh Permissions
FLUSH PRIVILEGES;
- 6. Exit MySQL
7. Restart MySQL
/etc/init.d/mysqld restart
- 8. Log back in to MySQL with the root user
CENTOS7 installation mysql-5.5.60