centos7如何安装mysql

1.下载mysql

yum install wget -y && wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.47.tar.gz

2.解压

tar -zxf mysql-5.6.47.tar.gz

3.切换到mysql解压目录下

cd mysql-5.6.47

4.添加mysql所属用户组

groupadd mysql

5.添加mysql所属用户

useradd -g mysql mysql -M -s /sbin/nologin

6.安装依赖

yum install gcc gcc-c++ openssl-devel cmake ncurses-devel autoconf -y

7.编译

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1

8.安装

make && make install

9.初始化数据库

/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql/

10.启动数据库

/usr/local/mysql/support-files/mysql.server start

如果启动数据库报这个错:Starting MySQL.200209 13:13:43 mysqld_safe error: log-error set to '/var/log/mariadb/mariadb.log', however file don't exists. Create writable for user 'mysql'.
The server quit without updating PID file (/var/lib/mysql/i[FAILED]bxhfa7bwajv2lZ.pid).
可以删掉/etc/my.cnf再启动

rm -f /etc/my.cnf

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: