Google Ads

Friday, November 14, 2008

Some good terminal commands to MySQL

Some good terminal commands to MySQL are:

Type on terminal to:

Change root password:
/usr/bin/mysqladmin -u root password "new_password"

Log without password
# mysql

If it output:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

That shows that mysql does not allow access as root without password.

If you log without a password it is good to put a password, use the same command to change root password.

Log with root user
# mysql -u root -p

Show databases
# show databases;

Choose a database
# use name_of_your_database;

Show tables;
# show tables;

Show MySQL users;
# select * from mysql.user;

Run a script
# source your_script.sql;

Give all privilege to a user
# grant all privileges on *.* to 'user'@localhost identified by 'your_password' WITH GRANT OPTION;

# flush privileges;

More infos visit

No comments: