Score:0

How to access mysql command line?

es flag

I am trying to set up PHP on my laptop with this link, but it says that I need to "Access the MySQL service command-line." I think I had it before, but then I lost it. Will you please help me? I know it says to do mysql -u root -p, but when I do that it says Enter Password:, but I don't know the password. It then says how to change the password, but you need to be on the command line to do it. You see my dilemma.

Score:0
cn flag

I believe from my point you haven't run mysql_secure_installation which help to enables and set password base auth for user root.

As you already mention that you follow that link where they haven't set the password for the root user they only create a standard user for their database.

Now how you can solve it all you need to do is run the below commands in order.

First, open the terminal by Ctrl+Alt+T or just search for the terminal.

Take the sudo access by running the below command:

sudo su

It will give you root access to your laptop. you can also avoid taking the root access but for that, you need to run every command using sudo at beginning of every command.

Run the security script with sudo:

sudo mysql_secure_installation

This will take you through a series of prompts where you can make some changes to your MySQL installation’s security options.

Select Y for every option you don't have to worry about anything it's just a just basic configuration of MySQL

once you are done with that now take access to your Mysql server:

sudo mysql -u root -p 

The password is which you have set up while running the command of sudo mysql_secure_installation

once you got into the terminal use create a user with all privileges.

for the run the below command:

CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost';

Warning: Don't run this command on the production server as such broad privileges should not be granted lightly, as anyone with access to this MySQL user will have complete control over every database on the server.

Following this, it’s good practice to run the FLUSH PRIVILEGES command. This will free up any memory that the server cached as a result of the preceding CREATE USER and GRANT statements:

FLUSH PRIVILEGES;

Then you can exit the MySQL client:

exit

In the future, to log in as your new MySQL user, you’d use a command like the following:

mysql -u user-p

The -p flag will cause the MySQL client to prompt you for your MySQL user’s password in order to authenticate.

by coming this far your problem will solve.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.