mysql operations via terminal

1.install mysql

apt-get install -y mysql-server python-mysqldb

sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf

restart mysql

service mysql restart

2.delete database

To delete a database from a MySQL server instance, we need to make a DROP DATABASE call against the server.

First, fire up MySQL in your terminal and login as an administrator account with:

mysql -u root -p

You will be prompted for your root password before being granted access to the MySQL monitor.

Now to grab a list of available databases on the system. Running:

show databases;

Will result in quite a list of available databases being drawn on the screen (note, it only lists the databases your user account has privileges to see). Once you have located the database you wish to delete in this list we can proceed:

drop database if exists mydatabase;

This will now delete the mydatabase database from the MySQL server if it exists. If not, the drop database statement is simply ignored.

3.delete an user account

To delete a user account from a MySQL server instance, we need to make use of a DROP USER call to the mysql.user table.

First, fire up MySQL in your terminal and login as an administrator account with:

mysql -u root -p

You will be prompted for your root password before being granted access to the MySQL monitor.

Now to grab a list of available user accounts on the system. Running:

select user,host from mysql.user;

Once you have spotted the account you wish to remove, run the following query:

drop user 'username'@'localhost';

转载于:https://my.oschina.net/u/238880/blog/77111

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值