hai, can somebody help me, how to change root password for mysql in CPANEL? i tried to put my website online, but it send message :

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in /home/akmajuco/public_html/_class/cms_class.php on line 9
Access denied for user 'root'@'localhost' (using password: YES)

i hope someone can help me.

Dani AI

Generated

As noted, most shared cPanel hosts manage the MySQL "root" account at the server level and do not allow account-level users to log in as or change that root account. The correct solution for a website reporting database authentication failures is to create (or use) a dedicated database and a non-root database user inside cPanel, grant that user the required privileges, and update the site’s DB configuration to use those credentials. See cPanel’s MySQL Databases documentation. (docs.cpanel.net)

Practical steps for an account on shared hosting:

  • Log in to cPanel and open “MySQL® Databases” (or the Database Wizard).
  • Create a new database, then create a new database user and strong password.
  • Use “Add User To Database” to grant the app the privileges it needs.
  • If changing an existing DB user’s password, use the Current Users → Change Password control in cPanel.
  • Update the website’s config (DB_NAME, DB_USER, DB_PASSWORD, DB_HOST) so the app connects with the non-root user. (docs.cpanel.net)

For administrators of a server with WHM/root access, cPanel provides a WHM interface to change the MySQL root password (WHM → SQL Services → MySQL Root Password), which also updates system files such as /root/.my.cnf. If WHM is not available, cPanel documents a supported manual method (init-file) and MySQL’s docs describe the safe SQL statements to reset a root password (for example, an ALTER USER statement). Any manual reset must also update /root/.my.cnf so cPanel can manage MySQL correctly. Example SQL form:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

(docs.cpanel.net)

Security and troubleshooting notes: never run production apps as MySQL root; use per-database accounts. Use strong passwords, and be aware cPanel warns that certain characters in the MySQL root password can break phpMyAdmin (avoid asterisks/periods for root if phpMyAdmin must be used). If there is no WHM/root access, the hosting provider’s support must perform any root-level password changes. (docs.cpanel.net)

Recommended Answers

All 2 Replies

Most hosts don't provide an option for this (and I don't think they will allow you to use root). I think you should use the username and password as provided by them. Also, you should be able to create new users in your cPanel, then you can create your own password.

haha, tq pritaes for the reply. i have solve it using your suggestion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.