-2

How can I set the database password for my sql database?

I am using ubuntu with apache, php, and my sql installed.

I followed this to create the database and import the sql file.

https://www.digitalocean.com/community/tutorials/how-to-import-and-export-databases-in-mysql-or-mariadb

Now I need to get my code to connect to the database.

How do I set the database password? Or is that just the mysql root password?

johnnyo1012
  • 9
  • 1
  • 5
  • This is the code I have to connect to the database... $databaseHost = 'localhost'; $databaseName = 'database_name'; $databaseUsername = 'root'; $databasePassword = 'password'; – johnnyo1012 Aug 12 '18 at 16:57
  • is the question how do you set a password for MYSQL or how do you connect to a mysql database using username and password? – Clint Aug 12 '18 at 17:55
  • @Clint Well does each database get its own password? I keep getting error root@localhost access denied but I have set the password correctlyz – johnnyo1012 Aug 12 '18 at 17:56
  • A database has users, the users have usernames and passwords. I still don't fully understand the original question you are asking. – Clint Aug 12 '18 at 18:11
  • @Clint I’m trying to connect my code to my database. Does each database have a username and password? I keep getting error root@localhost access denied – johnnyo1012 Aug 12 '18 at 18:25
  • what is the database connection code that you are using? – Clint Aug 12 '18 at 18:26
  • @Clint check the first comment. I posted 3 lines. My password is the password I set when installing MySQL. – johnnyo1012 Aug 12 '18 at 18:34
  • @Clint fixed it! Had to make an sql user and use that! Not the password you set during install! – johnnyo1012 Aug 12 '18 at 22:48
  • Possible duplicate of [Create new user in MySQL and give it full access to one database](https://stackoverflow.com/questions/1720244/create-new-user-in-mysql-and-give-it-full-access-to-one-database) – Christian Gollhardt Aug 15 '18 at 01:09

1 Answers1

0

Actually create a my sql user and not use the password set when installing my sql on apache server.

johnnyo1012
  • 9
  • 1
  • 5