您的位置:首页 > 财经 > 金融 > 唐山开发网站的公司_互联网排名前十的公司2021_seo快速优化软件网站_亚马逊跨境电商个人开店

唐山开发网站的公司_互联网排名前十的公司2021_seo快速优化软件网站_亚马逊跨境电商个人开店

2024/12/23 8:48:10 来源:https://blog.csdn.net/pang12234/article/details/142817128  浏览:    关键词:唐山开发网站的公司_互联网排名前十的公司2021_seo快速优化软件网站_亚马逊跨境电商个人开店
唐山开发网站的公司_互联网排名前十的公司2021_seo快速优化软件网站_亚马逊跨境电商个人开店

---------------------------------------------------------------------------------------------------------------------------------

1.前置准备

1.1 卸载旧版MySQL

1.2 查看rpm包

rpm -qa|grep mysql

若有可用 rpm -e 安装包 --nodeps

1.3 查找mysql残留包,有则删除,没有则忽略

find / -name mysql

1.4 安装相关依赖

yum -y install make gcc-c++ cmake bison-devel ncurses-devel numactl libaio autoconf

1.5 创建用户和用户组

groupadd mysql

useradd -g mysql mysql

1.6 创建mysql相关目录

mkdir -p /data/mysql/{data,logs,tmp}

# 更改文件夹所属

chown -R mysql.mysql /data/mysql/

---------------------------------------------------------------------------------------------------------------------------------

2.下载二进制安装包并解压

cd /usr/local/

# wget下载或者本地下载后上传(32/64)

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.23-linux-glibc2.12-x86_64.tar.gz

wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.35-linux-glibc2.12-i686.tar.gz

# 解压安装包

tar -zxvf mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz

#重命名为mysql

mv mysql-5.6.46-linux-glibc2.12-x86_64.tar.gz mysql

# 更改文件夹所属

chown -R mysql.mysql /usr/local/mysql/

---------------------------------------------------------------------------------------------------------------------------------

3.创建mysql配置文件my.cnf

vi /etc/my.cnf

# 添加如下内容:

[client]

port = 3306

socket = /data/mysql/tmp/mysql.sock

[mysqld]

skip-grant-tables

user = mysql

basedir = /usr/local/mysql

datadir = /data/mysql/data

port = 3306

socket = /data/mysql/tmp/mysql.sock

pid-file = /data/mysql/tmp/mysqld.pid

tmpdir = /data/mysql/tmp

skip_name_resolve = 1

symbolic-links=0

max_connections = 2000

group_concat_max_len = 1024000

sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

lower_case_table_names = 1

#character-set-server = utf8

#default-character-set=utf8

interactive_timeout = 1800

wait_timeout = 1800

max_allowed_packet = 32M

binlog_cache_size = 4M

sort_buffer_size = 2M

read_buffer_size = 4M

join_buffer_size = 4M

tmp_table_size = 96M

max_heap_table_size = 96M

max_length_for_sort_data = 8096

#logs

server-id = 1003306

log-error = /data/mysql/logs/mysqld.log

slow_query_log = 1

slow_query_log_file = /data/mysql/logs/slow.log

long_query_time = 3

log-bin = /data/mysql/logs/binlog

binlog_format = row

expire_logs_days = 15

log_bin_trust_function_creators = 1

relay-log = /data/mysql/logs/relay-bin

relay-log-recovery = 1

relay_log_purge = 1

#innodb

innodb_file_per_table = 1

innodb_log_buffer_size = 16M

innodb_log_file_size = 256M

innodb_log_files_in_group = 2

innodb_io_capacity = 2000

innodb_io_capacity_max = 4000

innodb_flush_neighbors = 0

innodb_flush_method = O_DIRECT

innodb_autoinc_lock_mode = 2

innodb_read_io_threads = 8

innodb_write_io_threads = 8

innodb_buffer_pool_size = 2G

---------------------------------------------------------------------------------------------------------------------------------

4.配置mysql.server

cd /usr/local/mysql/support-files

cp mysql.server /etc/init.d/mysql

vi /etc/init.d/mysql

# 修改目录位置

basedir=/usr/local/mysql

datadir=/data/mysql/data

# 注册开机启动服务(可选)

chkconfig --add mysql

chkconfig --list

---------------------------------------------------------------------------------------------------------------------------------

5.添加环境变量

(root用户)

echo "PATH=$PATH:/usr/local/mysql/bin " >> /etc/profile

source /etc/profile

(普通用户)

echo "PATH=$PATH:/usr/local/mysql/bin " >> /home/hadoop/.bash_profile

source /home/hadoop/.bash_profile

---------------------------------------------------------------------------------------------------------------------------------

6.初始化mysql

cd /usr/local/mysql/bin

./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data

# 临时密码保存在errlog中,获取临时密码

more /data/mysql/logs/mysqld.log |grep password

---------------------------------------------------------------------------------------------------------------------------------

7.启动mysql服务 并修改密码

# 启动mysql服务

service mysql start

# 使用初始密码登录mysql服务(初始为空,回车登录)并修改密码

mysql -u root -p

mysql> use mysql;

mysql> update user set password=password('root') where user='root';

mysql> grant all privileges on *.* to 'root'@'localhost' with grant option;

mysql> update user set host = '%' where user = 'root' and host= 'localhost';

mysql> flush privileges;

mysql> \q

5.7版本后使用以下命令:

mysql -u root -p

mysql>use mysql;

mysql>update mysql.user set authentication_string=password('root') where user='root';

mysql> flush privileges;

mysql> grant all privileges on *.* to 'root'@'localhost' with grant option;

mysql> flush privileges;

mysql>alter user 'root'@'localhost' identified by 'root';

mysql> flush privileges;

---------------------------------------------------------------------------------------------------------------------------------

8.mysql服务启动关闭

# service mysql stop

# service mysql start

---------------------------------------------------------------------------------------------------------------------------------

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com