I am using debian linux. I have a linux machine on which mysql is install. I can log in to my linux machine using root user as well as other user. I can connect to mysql database on linux machine from windows machine using sqlyog. Now I want to execute queries on linux machine only using linux terminal
I tried some following things on terminal
I went to root directory then I went to /var/lib directory
I run following commands on terminal
mysqladmin -u root -p
mysqladmin -u root -ppassword
everytime I have get following error message
ERROR 1045 (28000) Access denied for user 'root'@'localhost' (Using password NO)
please guide me for following
ERROR 1045 (28000) Access denied for user 'root'@'localhost' (Using password NO)
Please give me solutions for above question. Thank You
I had the same exact issue on my ArchLinux VPS today.
mysql -u root -p
just didn't work, whereas mysql -u root -pmypassword
did.
It turned out I had a broken /dev/tty device file (most likely after a udev upgrade), so mysql couldn't use it for an interactive login.
I ended up removing /dev/tty and recreating it with mknod /dev/tty c 5 1
and chmod 666 /dev/tty
. That solved the mysql problem and some other issues too.
Try "sudo mysql -u root -p" please.
To stop or start mysql on most linux systems the following should work:
/etc/init.d/mysqld stop
/etc/init.d/mysqld start
The other answers look good for accessing the mysql client from the command line.
Good luck!
At the command prompt try:
mysql -u root -p
give the password when prompted.
if you're already logged in as root just
mysql -u root
prompting the password will otherwise return as error
To your first question:
mysql -u root -p
or
mysqladmin -u root -p "your_command"
depending on what you want to do. The password will be asked of you once you hit enter! I'm guessing you really want to use mysql and not mysqladmin.
For restarting or stopping the MySQL-server on linux, it depends on your installation, but in the common debian derivatives this will work for starting, stopping and restarting the service:
sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql restart
sudo /etc/init.d/mysql status
In some newer distros this might work as well if MySQL is set up as a deamon/service.
sudo service mysql start
sudo service mysql stop
sudo service mysql restart
sudo service mysql status
But the question is really impossible to answer without knowing your particular setup.
I assume you are looking to use mysql client, which is a good thing and much more efficient to use than any phpMyAdmin alternatives.
The proper way to log in with the commandline client is by typing:
mysql -u username -p
Notice I did not type the password. Doing so would of made the password visible on screen, that is not good in multi-user environnment!
After typing this hit enter key, mysql will ask you for your password.
Once logged in, of course you will need:
use databaseName;
to do anything.
Good-luck.
if u got still no access to db, 1. in ur error message is set no password right? then first do mysqlpasswd 'username' after that enter and then give it a password type again as requested and then try to access again with mysql -p if you are root
In Ubuntu, all I have to do ran is sudo mysql
in GNOME terminal and that's it. I can start making databases or query a data in table, etc.
use this "mysql -uroot -pPassword"
you should use mysql
command. It's a command line client for mysql RDBMS, and comes with most mysql installations: http://dev.mysql.com/doc/refman/5.1/en/mysql.html
To stop or start mysql database (you rarely should need doing that 'by hand'), use proper init script with stop
or start
parameter, usually /etc/init.d/mysql stop
. This, however depends on your linux distribution. Some new distributions encourage service mysql start
style.
You're logging in by using mysql
sql shell.
The error comes probably because double '-p' parameter. You can provide -ppassword
or just -p
and you'll be asked for password interactively. Also note, that some instalations might use mysql (not root) user as an administrative user. Check your sqlyog configuration to obtain working connection parameters.
Source: Stackoverflow.com