内网linux 安装mysql
mysql下载地址正文:之前的其他笔记步骤有问题把安装包传到linux虚拟机1、在 /usr/local/ 目录下新建 mysql文件夹,2、解压 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz ,把mysql-5.7.22-linux-glibc2.12-x86_64 里的东西复制到 /usr/local/mysql下3、在/usr/local/mysql下
正文:
之前的其他笔记步骤有问题
把安装包传到linux虚拟机
1、在 /usr/local/ 目录下新建 mysql文件夹,
2、解压 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz ,把mysql-5.7.22-linux-glibc2.12-x86_64 里的东西复制到 /usr/local/mysql下
3、在/usr/local/mysql 下可以先新建 data文件夹
4、更改mysql目录下所有的目录及文件夹所属的用户组和用户,以及权限
useradd mysql
chown -R mysql:mysql /usr/local/mysql
chmod -R 755 /usr/local/mysql
5、编译安装并初始化mysql,务必记住初始化输出日志末尾的密码
(备注:数据库管理员临时密码,没有的话,可以试试先到my.cnf 下设置跳过密码检查)
如 ymAixGz5mm(I
cd /usr/local/mysql/bin
./mysqld --initialize --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql
6、到/etc 下找到 my.cnf ,下面这个覆盖进去(注意 datadir 的路径要对) ,
注意 第二行 user = root 一定得加
[mysqld]
user = root
datadir=/usr/local/mysql/data
port = 3306
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
max_connections=400
innodb_file_per_table=1
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
# include all files from the config directory
#!includedir /etc/my.cnf.d
(知识点: #表名大小写不明感,敏感为 lower_case_table_names=1)
7、然后:启动mysql服务器 /usr/local/mysql/support-files/mysql.server start
如果有下面问题时,可以先重启虚拟机试试,如果不行,参考第6步
再不行,就参考这个:PID问题
其内容为:
Starting MySQL. ERROR! The server quit without updating PID file (/usr/local/mysql/var/localhost.localdomain.pid).
- 99%权限问题
我的安装在 /usr/local
cd /usr/local
数据库目录 chown -R mysql:mysql mysql
8、添加软连接,并重启mysql服务 (这里建立了两个 /etc/init.d/mysql /usr/bin/mysql )
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
9、登录mysql,修改密码(密码为步骤5生成的临时密码)
mysql -u root -p
Enter password:
mysql>set password for root@localhost = password(‘123456’);
10、开放远程连接
mysql>use mysql;
msyql>update user set user.Host=’%’ where user.User=‘root’;
mysql>flush privileges;
11、设置开机自动启动 , 将服务文件拷贝到init.d下,并重命名为mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
12、赋予可执行权限
chmod +x /etc/init.d/mysqld
13、添加服务
chkconfig --add mysqld
14、显示服务列表
chkconfig --list
15、结束
相关资料https://blog.csdn.net/sinat_24393863/article/details/93506102?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Edefault-3.control
更多推荐
所有评论(0)