centos6.5 mysql 5.6修改root密码,以及创建用户并授权

时间:2023-03-10 05:59:11
centos6.5 mysql 5.6修改root密码,以及创建用户并授权
mkdir -p mysql_home/{data,temp,undologs,logs}
chown -R mysql:mysql /dbfiles/mysql_home
mysql_install_db --defaults-file=/etc/my.cnf --user=mysql
service mysql start
mysqladmin -u root password
输入密码,并确认,root密码修改完成
use mysql;
CREATE USER 'user'@'%' IDENTIFIED BY 'password';
grant all privileges on databasesname.* to user@'%' identified by 'password';
flush privileges;
commit;
my.cnf
[client]
socket=/dbfiles/mysql_home/data/mysql.sock [mysqld]
#General server parameters
datadir = /dbfiles/mysql_home/data
tmpdir= /dbfiles/mysql_home/temp
#skip-grant-tables
port =
server_id =
socket=/dbfiles/mysql_home/data/mysql.sock
#bind_address=0.0.0.0
character_set_server='utf8'
skip-name-resolve ## InnoDB specific parameters
innodb_undo_directory= /dbfiles/mysql_home/undologs
innodb_buffer_pool_size = 3G
innodb_file_per_table=ON
innodb_flush_log_at_trx_commit=
innodb_log_file_size=512M
innodb_flush_method=O_DIRECT ## Transaction behavior
autocommit=ON
transaction-isolation=READ-COMMITTED #slow_query
log_queries_not_using_indexes=
long_query_time=
slow_query_log= ## Memory sizes
join_buffer_size = 8M
sort_buffer_size = 8M
read_rnd_buffer_size = 8M tmp_table_size = 64M
max_heap_table_size = 64M ## Miscellaneous parameters
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER
default_storage_engine=InnoDB # max binlog keeps days
expire_logs_days = max_connections=
## Enables binary logging
relay_log=/dbfiles/mysql_home/logs/mysql-relay-bin.log
max_relay_log_size=512M
binlog_format=ROW
log_bin=/dbfiles/mysql_home/logs/binlog.log
max_binlog_size=512M
sync_binlog=
gtid_mode=ON
log_slave_updates=ON
enforce_gtid_consistency=ON ## Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links= #read_only=