Linux

关注公众号 jb51net

关闭
首页 > 网站技巧 > 服务器 > Linux > Linux下安装Mysql(mysql.tar.gz)

Linux系统下安装Mysql全过程(mysql.tar.gz)

作者:灬奔跑的蜗牛灬

该文章详细介绍了如何卸载、安装和配置MySQL数据库,包括添加用户组和用户、修改配置文件、授权、启动服务、添加开机启动项目、解决乱码问题等步骤

检查是否已经安装了Mysql

rpm -qa|grep mysql

卸载Mysql

rpm -e --nodeps 程序名

mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.22-linux-glibc2.12-x86_64 /usr/local/mysql
cd /usr/local/mysql
groupadd mysql
useradd -r -g mysql mysql
mkdir /usr/local/mysql/data
 chown -R mysql:mysql ./
 chown -R mysql:mysql data
yum install -y libaio
bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

cd support-files/
cp /usr/local/mysql/support-files/mysql.server  /etc/init.d/mysqld
vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data

bin/mysqld_safe --user=mysql &
//或者
service mysqld start 
chkconfig --add mysqld
//查看开机启动項
chkconfig --list

/etc/init.d/mysqld restart
./mysql -uroot -p 临时密码

发生错误

执行:

ln -s /usr/local/mysql/bin/mysql /usr/bin
set password= password('root');
//或者
alter user 'root'@'localhost' identified by 'root'; 
//刷新权限
flush privileges;
//授权新用户
GRANT ALL PRIVILEGES ON *.* TO 'root1'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;  

vi /etc/profile
//加入
PATH=/data/mysql/bin:/data/mysql/lib:$PATH
export PATH
//配置文件立即生效
source /etc/profile
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[client]

# pipe
# # socket=0.0
port=3306
default-character-set=utf8
[mysql]
port=3306
default-character-set=utf8
#
[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/usr/local/mysql/data
#socket=/var/lib/mysql/mysql.sock
server_id=1
expire_logs_days=3
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
port=3306
character-set-server=utf8

log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid
pid-file=/usr/local/mysql/data/localhost.localdomain.pid


总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:
阅读全文