MySql常用命令

mysql manual

install mysql for ubuntu

root@ubuntu:~# sudo apt-get install mysql-server
root@ubuntu:~# apt install mysql-client 
root@ubuntu:~# apt install libmysqlclient-dev 

# arch linux
yaourt -S mariadb

# systemctl start mariadb
# mysql_secure_installation
# systemctl restart mariadb

post install

# arch
    mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
# both
    mysql_secure_installation

initial

check mysql installation
sudo netstat -tap | grep mysql
mysql change ip addr
root@ubuntu:~# vi /etc/mysql/mysql.conf.d/mysqld.cnf
#bind-address = 127.0.0.1
  1. connect
mysql -u root -p
use mysql

# delete anonymous user
select user, host from user;
delete from user where host='localhost' and user='';
  1. unicode support
    server side
[mysqld]
collation-server = utf8_unicode_ci
init-connect='SET NAMES utf8'
character-set-server = utf8

client side

default-character-set = utf8

remote connect

  1. edit my.cnf
    in [mysqld]
bind-address=192.168.1.100
# skip-networking
  1. restart mysql
login to mysql and create database with user 3. grant access to remote IP address
create database ros;
grant all on database_name.* to username@'%' identified by 'password';
grant all on cityrobot.* to ros@'%' identified by 'ros';
grant all on ros.* to ros@'%' identified by 'Roos123@';
-- or
grant all on foo.* to bar@'remote_ip' identified by 'password' with grant option;

remote_ip is the address where the client is on

grant access to an existing database

update db set Host='remote_ip' where Db='webdb';
update user set Host='remote_ip' where user='webadmin';

创建用户后flush privileges; then restart mysql

flush privileges;
/etc/init.d/mysql restart
  1. test it
mysql -u webadmin -h server_ip -p
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql -uroot -p
mysql> uninstall plugin validate_password;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值