卸载centos7自带的mariadb
rpm -qa|grep mariadb #查看一下是否有mariadb相关的包
rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64 #把查询到的包卸载
wget https://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.60.tar.gz
wget https://cmake.org/files/v3.10/cmake-3.10.2.tar.gz
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql # -s /sbin/nologin 表示禁止该用户登录,加强安全; -g mysql 指定属于mysql组; -M 表示不创建用户家目录
yum install ncurses-devel -y
tar zxvf cmake-3.10.2.tar.gz -C /usr/local
cd /usr/local/cmake-3.10.2
./configure
gmake && gmake install
tar zxvf mysql-5.5.60.tar.gz
cd mysql-5.5.60
cmake . -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=0
make && make install
做软连接
ln -s /application/mysql-5.5.60/ /application/mysql
mysql目录授权
chown -R mysql:mysql /application/mysql-5.5.60/
复制相关文件
cd /application/mysql/support-files
cp my-small.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
/etc/init.d/mysqld start
echo ‘export PATH=/application/mysql/bin:$PATH‘>>/etc/profile
source /etc/profile
/application/mysql//bin/mysqladmin -u root password ‘zacs164.com‘
设置mysql开机启动
chkconfig mysqld on
chkconfig --list mysqld #查看一下
正常的情况是可以正常登陆进去的,但是我在登录的时候报了以下错误信息:
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
解决方法:
/etc/init.d/mysqld stop
mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
mysql -u root mysql
UPDATE user SET Password=PASSWORD(‘ZACS164.COM‘) where USER=‘root‘;
FLUSH PRIVILEGES;
7.重启mysql
/etc/init.d/mysqld restart
原文:http://blog.51cto.com/888888hfer/2161677