cd /mydata/data
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
tar xzf mysql-5.7.24-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.24-linux-glibc2.12-x86_64 /usr/local/mysql
mkdir /usr/local/mysql/data
查看mysql用户组是否存在
grep mysql /etc/group
不存在则创建
groupadd -g 27 mysql
查看mysql用户是否存在
grep mysql /etc/passwd
不存在则创建
useradd mysql -g mysql -M -s /sbin/nologin
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --explicit_defaults_for_timestamp=off
报错
./mysqld: error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
yum -y install libaio-devel.x86_64
yum -y install numactl
重新安装
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --explicit_defaults_for_timestamp=off
记录日志最末尾位置root@localhost:后的字符串,此字符串为mysql管理员临时登录密码。
root@localhost: /vrkcT,ku0,p
编辑配置文件my.cnf,添加配置如下
vi /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
port=3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
symbolic-links=0
max_connections=600
innodb_file_per_table=1
lower_case_table_names=1
[mysqld_safe]
log-error=/usr/local/mysql/error.log
pid-file=/usr/local/mysql/mysql.pid
启动
touch /usr/local/mysql/error.log
chmod 755 /usr/local/mysql/error.log
/usr/local/mysql/support-files/mysql.server start
报错
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/data/VM_22_123_centos.pid).
解决方法
mv /etc/my.cnf /etc/my.cnf.backup
重新启动
/usr/local/mysql/support-files/mysql.server start
netstat -lntp
创建软连接
ln -s /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
service mysql restart
修改密码
mysql -u root -p
Enter password:
mysql>set password for root@localhost = password('%&q12nhkaDbvsi4894y');
开放远程连接
mysql>use mysql;
msyql>update user set user.Host='%' where user.User='root';
mysql>flush privileges;
设置开机自动启动
1、将服务文件拷贝到init.d下,并重命名为mysql
[root@localhost /]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
2、赋予可执行权限
[root@localhost /]# chmod +x /etc/init.d/mysqld
3、添加服务
[root@localhost /]# chkconfig --add mysqld
4、显示服务列表
[root@localhost /]# chkconfig --list
linux下安装mysql57
最新推荐文章于 2024-07-23 09:58:04 发布