mysql安装
young / / / 阅读量

#mysql安装

环境

centos6.5

mysql5.6.41(二进制包)

安装

上传mysql安装包

解压压缩包

[root@localhost]# mkdir /mysql
[root@localhost]# tar vf mysql-5-4-41.tar.gz -C /mysql

创建mysql用户,把mysql文件夹权限给mysql用户

[root@localhost]# chown –R mysql:mysql /mysql

配置

修改配置文件 /etc/my.cnf 服务器配置不同,配置不同

[client]
port = 3306 
socket = /tmp/mysql.sock
[mysql]
no-auto-rehash
default-character-set=utf8mb4
[mysqld]
user = root 
port = 3306 
socket = /tmp/mysql.sock 
secure_file_priv=/root
basedir = soft_path
datadir = data_path
skip-name-resolve
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
lower_case_table_names = 1 
max_connections = 1000
max_connect_errors = 10000
transaction_isolation = READ-COMMITTED
sql_mode = "STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER"
skip-external-locking
join_buffer_size = 512M
tmp_table_size = 64M
tmpdir = /tmp
max_allowed_packet = 64M
read_buffer_size = 16M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
back_log=128
key_buffer_size=1024M
thread_stack=256k
thread_cache_size=64
query_cache_type=1
query_cache_size=128M
query_cache_limit = 10M
max_heap_table_size=256M
binlog_cache_size = 2M
table_open_cache=128
log_error = soft_path/logs/error.log
general_log = 1
general_log_file = soft_path/logs/general.log
slow_query_log = 1
long_query_time = 10
slow_query_log_file = soft_path/logs/slow.log
log-bin=master-bin
log-bin-index=master-bin.index
sync_binlog=5
sync_relay_log=1000
relay_log_recovery = 1
server_id=master1
replicate-wild-ignore-table = mysql.%
replicate-wild-ignore-table = information\_schema.%
replicate-wild-ignore-table = sys.%
replicate-wild-ignore-table = performance\_schema.%
auto-increment-increment = 2  
auto-increment-offset = 1   
slave-skip-errors = ddl_exist_errors
expire_logs_days=7
binlog_format=MIXED
innodb_buffer_pool_size=1G
innodb_buffer_pool_instances = 8
innodb_log_file_size=128M
innodb_log_buffer_size = 3M
innodb_flush_log_at_trx_commit=1
innodb_file_per_table=1
innodb_flush_method=O_DIRECT
innodb_io_capacity=2000
innodb_thread_concurrency = 2
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout

初始化数据库

#进入mysql目录
[root@localhost]# cd /mysql/mysql-5.5.41/
#mysql5.5
[root@localhost]# ./scripts/mysql_install_db
#5.7初始化数据库有变化
[root@localhost]# ./bin/mysqld --defaults-file=/etc/my.cnf  --initialize-insecure --user=root

启动数据库

[root@localhost]# cp /mysql/mysql-5.5.41/support-files/mysql.server /etc/init.d/mysql
[root@localhost]# service mysql start

设置用户

#设置root密码
[root@localhost]# /mysql/mysql-5.5.41/bin/mysqladmin -u root password 'new-password'
#进入mysql服务
[root@localhost]# /mysql/mysql-5.5.41/bin/mysql -uroot -p
#创建授权用户
GRANT ALL PRIVILEGES ON . TO 'test'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION;

5.7变化

#5.7修改密码
update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost'; 
#5.7查询用户
select user,host,authentication_string from mysql.user; 
#5.7数据库授权
GRANT ALL PRIVILEGES ON . TO 'test'@'%'IDENTIFIED BY '123456' WITH GRANT OPTION; 
支付宝捐赠
请使用支付宝扫一扫进行捐赠
微信捐赠
请使用微信扫一扫进行赞赏
有 0 篇文章