Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (6.1k points)

I am a Debian Linux user. I have installed MySQL on my Linux machine. I am able to log into the Linux machine using the root user as well as other users. I am able to connect to MySQL database on a Linux machine from a windows machine using sqlyog. So now I need to execute queries on Linux machine only using Linux terminal

I tried the following commands: 

I went to root directory then I went to /var/lib directory

mysqladmin -u root -p mysqladmin -u root -password

every time I have got following error message

ERROR 1045 (28000) Access denied for user 'root'@'localhost' (Using password NO)

Please help me out with the following things given down below: 

  1. In what way I can get MySQL prompt in the Linux terminal?

  2. How can I stop the MySQL server from the Linux terminal?

  3. What is the procedure to start the MySQL server from the Linux terminal?

  4. In what way I can get MySQL prompt in the Linux terminal?

  5. What is the procedure to log in to the MySQL server from the Linux terminal?

1 Answer

0 votes
by (11.7k points)

I am going to answer it one by one. 

1 You can get MySQL prompt in Linux using:

mysql -u root -p

At the Enter password:  please enter the root password

2. You can stop the MySQL server from the Linux terminal using the following command:

Red Hat-based distros have the service command:

service mysqld stop

Other distros require to call the init script directly:

/etc/init.d/mysqld stop

3. You can start the MySQL server from the Linux terminal same as point2, but with start.

4. You can get the MySQL prompt in the Linux terminal by using point 1.

5. You can log in to the MySQL server from the Linux terminal by the same procedure as mentioned in point 1.

If you want to get more insights into SQL, check out this SQL Course from Intellipaat.

Related questions

0 votes
1 answer
asked Dec 19, 2020 in SQL by Appu (6.1k points)
0 votes
0 answers
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...