- 下载linux版mysql
- 上传到服务器,解压到自己想要的目录,并重命名为mysql
- 先检查是否有mysql用户组和mysql用户:groups mysql
- 没有就添加:groupadd mysql && useradd -r -g mysql mysql,有就忽略
- 进入mysql目录:cd mysql 修改权限: chown -R mysql:mysql ./
- 安装依赖库 yum -y install autoconf && yum install libaio* -y && yum -y install numactl
- 执行安装脚本 ./scripts/mysql_install_db --user=mysql
- 安装完之后修改当前目录拥有者为root用户,修改data目录拥有者为mysqlchown -R root:root ./chown -R mysql:mysql data
- 创建默认日志文件 mkdir /var/log/mariadb && touch /var/log/mariadb/mariadb.log
- 启动mysql ./support-files/mysql.server start
- 一般情况下,启动会报错
./support-files/mysql.server: line 264: cd: /usr/local/mysql: No such file or directoryStarting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
- 解决方法:按下图修改/mysql/support-files/mysql.server的启动脚本,注意是从66行开始,别改错了
- 修改成功后,重新启动 ./support-files/mysql.server start
- 启动成功后,修改root账户密码 ./bin/mysqladmin -u root -h localhost.localdomain password '123456'
- 登陆mysql ./bin/mysql -h127.0.0.1 -uroot -p123456
- 授权远程登陆 grant all privileges on *.* to root@'%' identified by '123456'; flush privileges;
- 【mysql5.6 开机自启动】 1,将服务文件复制一份到init.d下,并重命名为mysqld cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 2,对文件赋予执行权限 chmod x /etc/init.d/mysqld 或 chmod 777 /etc/init.d/mysqld 3,增加mysqld服务 chkconfig --add mysqld 4,查询mysqld服务情况 chkconfig --list mysqld
5, 如果3,4,5 为off: chkconfig --level 345 mysqld on 6, 重启服务器验证:reboot