linux安装mysql
安装环境:
- 操作系统:腾信云购买centos 单核1G内存
- mysql版本:mysql Ver 14.14 Distrib 5.6.41, for linux-glibc2.12 (x86_64) using EditLine wrapper
步骤:
- 官网下载 Mysql 安装包
- 上传到服务器(目录 usr/local/software),然后解压
- tar -zxvf mysql-5.6.41-linux-glibc2.12-x86_64.tar.gz
- 拷贝安装目录(我安装目录 /usr/local/mysql)
- cp -r /usr/local/software/mysql-5.6.41-linux-glibc2.12-x86_64/* /usr/local/mysql
- 加角色
- groupadd mysql
- useradd -g mysql mysql
- 配置文件
- cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
- chmod 755 /etc/init.d/mysqld
- cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
- 安装
- /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql
- 启动mysql
- service mysql start
- 初始登录密码
- /usr/local/mysql/bin/mysqladmin -u root password '123456'
- 登录
- mysql -u root -p
- 设置外网账号登录
- GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
- FLUSH PRIVILEGES;
- 设置外网访问端口
- firewall -cmd --permanent --add-prot=3306/tcp
至此,大功告成