centos7下的mysql的编译安装
分享
大苹果
2023-12-03 20:23
1898
准备工作
- 依赖安装
yum -y install make gcc-c++ cmake bison-devel ncurses-devel
yum install -y gcc gcc-c++ kernel-devel
yum install -y readline-devel pcre-devel openssl-devel openssl zlib zlib-devel pcre-devel
- 编译安装
```bash
gzip -d mysql-5.6.29.tar.gz
tar -xvf mysql-5.6.29.tar
cd mysql-5.6.29/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/usr/local/mysql/data \
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci
make && make install - 配置
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
cd /usr/local/mysql
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
cp support-files/mysql.server /etc/init.d/mysql
rm -rf /etc/my.cnf
chkconfig mysql on
service mysql start
ln -s /usr/local/mysql/bin/mysql /usr/bin/
- 设置密码与赋予权限
mysql
然后开始给数据库管理员设置密码和访问权限grant all on *.* to username@"192.168.%" identified by "123456";
FLUSH PRIVILEGES;
exit;
--local-infile=0
CREATE USER 'dog'@'localhost' IDENTIFIED BY '123456';
CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '123456';
CREATE USER 'pig'@'%' IDENTIFIED BY '';
CREATE USER 'pig'@'%';
flush privileges;