欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

mysql5.6Linux下安装

程序员文章站 2022-05-27 09:26:52
...

mysql5.6Linux下安装

下载相关地址:链接:https://pan.baidu.com/s/1RorPrEOqpi8uhvj6dEp7mg
提取码:47eu

#关闭防火墙
service iptables stop
#永久关闭:chkconfig iptables off 重启生效:reboot
#创建文件夹上传文件到apps下
mkdir -p /apps
#解压关文件
tar zxvf mysql-5.6.31-linux-glibc2.5-x86_64.tar.gz
cd /apps
#软链接就是:“ln –s 源文件 目标文件”,只会在选定的位置上生成一个文件的镜像,不会占用磁盘空间,类似与windows的快捷方式。
ln -sf /apps/mysql-5.6.31-linux-glibc2.5-x86_64 /usr/local/mysql

groupadd mysql  
useradd mysql -g mysql -p mysql123456 -s /sbin/nologin -M
mkdir /var/run/mysqld -p
mkdir /apps/mysql-5.6.31-linux-glibc2.5-x86_64/data -p
chown -R mysql:mysql /var/run/mysqld

#一起执行start
echo “[client]” > /etc/my.cnf
echo “default-character-set=utf8” >> /etc/my.cnf
echo “socket=/apps/mysql-data/mysql.sock” >> /etc/my.cnf
echo “[mysqld]” >> /etc/my.cnf
echo “datadir=/apps/mysql-data” >> /etc/my.cnf
echo “socket=/apps/mysql-data/mysql.sock” >> /etc/my.cnf
echo “symbolic-links=0” >> /etc/my.cnf
echo “skip-name-resolve” >> /etc/my.cnf
echo “character-set-server=utf8” >> /etc/my.cnf
echo “max_connections=1000” >> /etc/my.cnf
echo “lower_case_table_names=1” >> /etc/my.cnf
echo “[mysqld_safe]” >> /etc/my.cnf
echo “log-error=/var/log/mysqld.log” >> /etc/my.cnf
echo “pid-file=/var/run/mysqld/mysqld.pid” >> /etc/my.cnf
#end

#一起执行start
cd /apps/mysql-5.6.31-linux-glibc2.5-x86_64 &&
chown -R mysql . &&
chgrp -R mysql . &&
#bin/mysqld --initialize --user=mysql &&
scripts/mysql_install_db
–basedir=/apps/mysql-5.6.31-linux-glibc2.5-x86_64
–datadir=/apps/mysql-data --user=mysql &&
chown -R root . &&
chown -R mysql data
#end
cp /apps/mysql-5.6.31-linux-glibc2.5-x86_64/support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod 700 /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 345 mysqld on
service mysqld start

#Linux下修改Mysql的用户(root)的密码通过登录mysql系统,
mysql -uroot -p(如果出现 #-bash: mysql: command not found 解决方案: ln -s /usr/local/mysql/bin/mysql /usr/bin
Enter password: 【输入原来的密码】 回车(首次登录无密码)如果(
#ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/apps/mysql-data/mysql.sock’ (2)
#先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动
#确定你的mysql.sock是不是在那个位置,
#mysql -u root -p -S /var/lib/mysql/mysql.sock
#试试:service mysqld start
#如果是权限问题,则先改变权限 #chown -R mysql:mysql /apps/mysql-data/mysql.sock)
mysql>use mysql;
mysql> update user set password=passworD(“123456”) where user=‘root’;
开放root:远程连接
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘123456’ WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON . TO ‘root’@‘localhost’ IDENTIFIED BY ‘pa44w0rd’ WITH GRANT OPTION;
mysql> flush privileges;

相关标签: mysql5.6 的安装