MySQL 安装
Linux 安装 MySQL
卸载、删除
rpm -qa|grep -i mysql
rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64
find / -name mysql
rm -rf /var/lib/mysql
下载、解压
-bash: wget: command not found
yum install wget -y
tar -zxvf mysql-5.5.62-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.5.62-linux-glibc2.12-x86_64 /usr/local/mysql
添加用户组、权限
groupadd mysql
useradd -g mysql mysql
chown -R mysql:mysql /usr/local/mysql
添加数据库文件目录
mkdir mysql
pwd /data/mysql
安装mysql
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/data/mysql
启动配置
cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql
lower_case_table_names=1 #忽略数据库表大小写
group_concat_max_len=102400
slow_query_log =1 #慢查询开启状态 1 为开启
slow_query_log_file=/data/mysql/query-slow.log #慢查询日志存放的位置
long_query_time = 1 #查询超过多少秒才记录 默认10秒 修改为1秒
设置开机自动启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
添加软链
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
启动、登陆
service mysqld start
mysql -uroot -p
修改密码
set password for root@localhost = password('输入密码');
添加运程
grant all privileges on *.* to root@'%' identified by '输入密码';
flush privileges;
防火墙状态
systemctl status firewalld
service iptables status
暂时关闭防火墙
systemctl stop firewalld
service iptables stop
永久关闭防火墙
systemctl disable firewalld
chkconfig iptables off
重启防火墙
systemctl enable firewalld
service iptables restart

浙公网安备 33010602011771号