1、下载mysql:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2、解压:tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
3.复制解压后的mysql目录:cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
4、添加用户组:groupadd mysql
5、添加用户mysql到用户组mysql:useradd -g mysql mysql
6、进到mysql安装目录:cd /usr/local/mysql
7、修改目录拥有者为mysql用户:chown -R mysql:mysql ./
8、安装mysql数据库:./scripts/mysql_install_db --user=mysql
注*:报错:FATAL ERROR: please install the following Perl modules before executing scripts/mysql_install_db:Data::Dumper
解决方法:yum install -y perl-Data-Dumper
报错: /usr/bin/perl:
解决方法:yum install perl gcc kernel-devel
9、修改当前目录拥有者为root用户:chown -R root:root ./
10、修改当前data目录拥有者为mysql用户:chown -R mysql:mysql data
11、添加mysql服务开机自启动:cp support-files/mysql.server /etc/init.d/mysql
12、赋予可执行权限:chmod +x /etc/init.d/mysql
13、添加服务:chkconfig --add mysql
14、显示服务列表:chkconfig --list
注*:如果看到mysql的服务,并且3,4,5都是on的话则成功,如果是off,则执行:chkconfig --level 345 mysql on
15、创建缺少的文件夹:mkdir /var/log/mariadb
16、使用软连接把mysql客户端放到默认路径:ln -s /usr/local/mysql/bin/mysql /usr/local/bin/mysql
17、启动mysql服务:service mysql start
18、用mysql用户登录数据库:mysql -u mysql -p
注*:报错:ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’
解决方法:ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
18、关闭mysql:service mysql stop
19、查看运行状态:service mysql status
Centos安装mysql
最新推荐文章于 2024-06-19 10:58:29 发布