sudo /etc/init.d/mysql restart #重启mysql服务
sudo service mysql status #查看mysql运行状况
创建新用户登录mysql
设置root密码之后,依然无法在linux非root账户下登录mysql.
mysql -uroot -p
#ERROR 1698 (28000): Access denied for user ''root''@''localhost''
此时需要登录linux的root账户,登录mysql:
mysql -uroot -p
#输入`mysql root`账户密码,登录mysql
mysql操作:
#创建新用户
mysql> CREATE USER ''DBTester''@''localhost'' IDENTIFIED BY ''yourPassword'';
#创建数据库
mysql> create database TEST;
#赋予用户权限
grant all privileges on TEST.* to ''DBTester''@''localhost'';
#linux登录至root账户
#登录mysql root账户
mysql -uroot -p
#使用mysql数据库
use mysql;
#查看密码插件,会发现现阶段root账户对应插件是auth_socket
select user,host,plugin,authentication_string from mysql.user;
#更换密码插件至mysql_native_password
update user set authentication_string="123" where user="root";
#注意,此时需要设置密码(使用以下语句可见密码为空)
select user,host,plugin,authentication_string from mysql.user;
#设置root账户密码
update user set password=password("yourpassword") where user="root";
flush privileges;
exit
kevin@uc:~/Downloads/<span>mac$ ll
total 173M
drwxrwxr</span>-x 2 kevin kevin 4.0K 9月 25 16:20 .<span>
drwxr</span>-xr-x 8 kevin kevin 4.0K 9月 29 13:59 ..
-rw-rw-r-- 1 kevin kevin 150M 9月 25 16:20 Navicat Premium <span>for</span> Mac 11.0.20 中文版.<span>dmg
</span>-rw-rw-r-- 1 kevin kevin 26 9月 25 16:20 Navicat Premium <span>for</span> Mac 11.0.20 中文版.dmg:Zone.<span>Identifier
</span>-rw-rw-r-- 1 kevin kevin 12M 9月 3 10:35 synergy-1.5.1-r2398-MacOSX108-x86_64.<span>dmg
</span>-rw-rw-r-- 1 kevin kevin 12M 9月 3 10:36 synergy-1.5.1-r2398-MacOSX109-x86_64.dmg
####################配置文件开始###################
# For advice on how to change settings please see
# http://dev.MysqL.com/doc/refman/5.7/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install,and will be replaced if you
# *** upgrade to a newer version of MysqL.
[client]
default-character-set=utf8
[MysqLd]
port=3306
basedir ="C:\job\MysqL-5.7.12-winx64/"
datadir ="C:\job\MysqL-5.7.12-winx64/data/"
tmpdir ="C:\job\MysqL-5.7.12-winx64/data/"
socket ="C:\job\MysqL-5.7.12-winx64/data/MysqL.sock"
log-error="C:\job\MysqL-5.7.12-winx64/data/MysqL_error.log"
#server_id = 2
#skip-locking
max_connections=100
table_open_cache=256
query_cache_size=1M
tmp_table_size=32M
thread_cache_size=8
innodb_data_home_dir="C:\job\MysqL-5.7.12-winx64/data/"
innodb_flush_log_at_trx_commit =1
innodb_log_buffer_size=128M
innodb_buffer_pool_size=128M
innodb_log_file_size=10M
innodb_thread_concurrency=16
innodb-autoextend-increment=1000
join_buffer_size = 128M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
max_allowed_packet = 32M
explicit_defaults_for_timestamp=true
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
skip-grant-tables
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
####################配置文件结束###################
MysqL Curoot
MysqL>show databases;
MysqL>use MysqL;
MysqL> update MysqL.user set authentication_string=password('12345') where user='root' and Host = 'localhost';
MysqL> alter user 'root'@'localhost' identified by '12345';
MysqL> FLUSH PRIVILEGES;
MysqL> QUIT
Windows server 2008 r2下MySQL5.7.17 winx64安装版配置方法图文教程
mysqld_multi配置MySQL多实例_MySQL
# this is an example of a my.cnf file for mysqld_multi. # usually this file is located in home dir ~/.my.cnf or /etc/my.cnf # # some important notes follow: # # 1.common user # # make sure that the mysql user, who is stopping the mysqld services, has # the same password to all mysql servers being accessed by mysqld_multi. # this user needs to have the ''shutdown_priv'' -privilege, but for security # reasons should have no other privileges. it is advised that you create a # common ''multi_admin'' user for all mysql servers being controlled by # mysqld_multi. here is an example how to do it: # # grant shutdown on *.* to multi_admin@localhost identified by ''password'' # # you will need to apply the above to all mysql servers that are being # controlled by mysqld_multi. ''multi_admin'' will shutdown the servers # using ''mysqladmin'' -binary, when ''mysqld_multi stop'' is being called. # # 2.pid-file # # if you are using mysqld_safe to start mysqld, make sure that every # mysql server has a separate pid-file. in order to use mysqld_safe # via mysqld_multi, you need to use two options: # # mysqld=/path/to/mysqld_safe # ledir=/path/to/mysqld-binary/ # # ledir (library executable directory), is an option that only mysqld_safe # accepts, so you will get an error if you try to pass it to mysqld directly. # for this reason you might want to use the above options within [mysqld#] # group directly. # # 3.data directory # # it is not advised to run many mysql servers within the same data directory. # you can do so, but please make sure to understand and deal with the # underlying caveats. in short they are: # - speed penalty # - risk of table/data corruption # - data synchronising problems between the running servers # - heavily media (disk) bound # - relies on the system (external) file locking # - is not applicable with all table types. (such as innodb) # trying so will end up with undesirable results. # # 4.tcp/ip port # # every server requires one and it must be unique. # # 5.[mysqld#] groups # # in the example below the first and the fifth mysqld group was # intentionally left out. you may have ''gaps'' in the config file. this # gives you more flexibility. # # 6.mysql server user # # you can pass the user=... option inside [mysqld#] groups. this # can be very handy in some cases, but then you need to run mysqld_multi # as unix root. # # 7.a start-up manage script for mysqld_multi # # in the recent mysql distributions you can find a file called # mysqld_multi.server.sh. it is a wrapper for mysqld_multi. this can # be used to start and stop multiple servers during boot and shutdown. # # you can place the file in /etc/init.d/mysqld_multi.server.sh and # make the needed symbolic links to it from various run levels # (as per linux/unix standard). you may even replace the # /etc/init.d/mysql.server script with it. # # before using, you must create a my.cnf file either in /usr/my.cnf # or /root/.my.cnf and add the [mysqld_multi] and [mysqld#] groups. # # the script can be found from support-files/mysqld_multi.server.sh # in mysql distribution. (verify the script before using) #