Browsed by
Author: priya

How to Update database permissions/privilages

How to Update database permissions/privilages

mysql> flush privileges; To update database permissions or privileges in MySQL, you typically use the GRANT and REVOKE statements. Here’s how you can do it: Granting Permissions: To grant permissions to a user, you can use the GRANT statement followed by the specific privileges and the database or tables the user should have access to. For example: sql GRANT SELECT, INSERT ON mydatabase.* TO ‘myuser’@’localhost’; This grants the SELECT and INSERT privileges on all tables in the mydatabase database to…

Read More Read More

How to update info already in a table and Delete a row(s) from a table

How to update info already in a table and Delete a row(s) from a table

mysql> UPDATE [table name] SET Select_priv = ‘Y’,Insert_priv = ‘Y’,Update_priv = ‘Y’ where [field name] = ‘user’; mysql> DELETE from [table name] where [field name] = ‘whatever’; To update information already in a MySQL table, you can use the UPDATE statement. Here’s the syntax: sql UPDATE table_name SET column1 = value1, column2 = value2, … WHERE condition; This will update the values in the specified columns for the rows that meet the specified condition. To delete row(s) from a MySQL…

Read More Read More

How to give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs

How to give user privilages for a db. Login as root. Switch to the MySQL db. Grant privs. Update privs

# mysql -u root -p # mysql -u root -p mysql> use mysql; mysql> INSERT INTO user (Host,Db,User,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv) VALUES (‘%’,’databasename’,’username’,’Y’,’Y’,’Y’,’Y’,’Y’,’N’); mysql> flush privileges; or mysql> grant all privileges on databasename.* to username@localhost; mysql> flush privileges To give user privileges for a specific database in MySQL, you would typically follow these steps: Login as root: Use the mysql command-line tool to log in as the root user, providing the appropriate credentials. bash mysql -u root -p Switch to the MySQL database:…

Read More Read More

How to allow the user “sonia” to connect to the server from localhost using the password “passwd”. Login as root.

How to allow the user “sonia” to connect to the server from localhost using the password “passwd”. Login as root.

How to allow the user “sonia” to connect to the server from localhost using the password “passwd”. Login as root. Switch to the MySQL db. Give privs. Update privs # mysql -u root -p mysql> use mysql; mysql> grant usage on *.* to sonia@localhost identified by ‘passwd’; mysql> flush privileges; To allow the user “sonia” to connect to the MySQL server from localhost using the password “passwd” and grant necessary privileges, you can follow these steps: Log in to MySQL…

Read More Read More

How to Update a root password

How to Update a root password

# mysqladmin -u root -p oldpassword newpassword To update the root password in MySQL, you can follow these steps: Log in to MySQL as the root user: bash mysql -u root -p Enter the current root password when prompted. Once logged in, use the following SQL command to update the root password: sql ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘new_password’; Replace ‘new_password’ with your desired new password. After updating the password, flush the privileges to apply the changes: sql FLUSH PRIVILEGES;…

Read More Read More

How to set a root password if there is on root password

How to set a root password if there is on root password

# mysqladmin -u root password newpassword If you want to set a root password for MySQL when there is no root password, you can follow these steps: Login to MySQL as the root user (without a password): bash mysql -u root Set a new password for the root user: sql ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘your_new_password’; Replace your_new_password with the desired password. Flush privileges to apply the changes: sql FLUSH PRIVILEGES; Exit the MySQL shell: sql exit; After completing these…

Read More Read More

How to Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables.

How to Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables.

How to Recover a MySQL root password. Stop the MySQL server process. Start again with no grant tables. Login to MySQL as root. Set new password. Exit MySQL and restart MySQL server # /etc/init.d/mysql stop # mysqld_safe –skip-grant-tables & # mysql -u root mysql> use mysql; mysql> update user set password=PASSWORD(“newrootpassword”) where User=’root’; mysql> flush privileges; mysql> quit # /etc/init.d/mysql stop # /etc/init.d/mysql start Yes, the steps you provided are generally correct for recovering a MySQL root password. Here’s a…

Read More Read More

How to Change a users password from MySQL prompt. Login as root. Set the password. Update privs

How to Change a users password from MySQL prompt. Login as root. Set the password. Update privs

# mysql -u root -p mysql> SET PASSWORD FOR ‘user’@’hostname’ = PASSWORD(‘passwordhere’); mysql> flush privileges; To change a user’s password in MySQL from the MySQL prompt while logged in as the root user, you can use the following steps: Log in to MySQL as the root user: sql mysql -u root -p You will be prompted to enter the root password. Change the user’s password: sql ALTER USER ‘username’@’host’ IDENTIFIED BY ‘new_password’; Replace ‘username’ with the actual username, ‘host’ with…

Read More Read More

How to Change a users password from unix shell

How to Change a users password from unix shell

# [mysql dir]/bin/mysqladmin -u username -h hostname.blah.org -p password ‘new-password’ To change a user’s password in MySQL from the MySQL prompt while logged in as the root user, you can use the following steps: To change a MySQL user’s password from the Unix shell, you can use the mysqladmin command. Here’s an example: bash mysqladmin -u <username> -p password <new_password> Replace <username> with the actual username for which you want to change the password, and <new_password> with the desired new…

Read More Read More

How to Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs

How to Creating a new user. Login as root. Switch to the MySQL db. Make the user. Update privs

# mysql -u root -p mysql> use mysql; mysql>INSERTINTO user (Host,User,Password) VALUES(‘%’,’username’,PASSWORD(‘password’)); mysql> flush privileges; To create a new user in MySQL, you can follow these steps: Login as root: bash mysql -u root -p You will be prompted to enter the root password. Switch to the MySQL database: sql USE mysql; Create the new user: sql CREATE USER ‘new_user’@’localhost’ IDENTIFIED BY ‘password’; Replace ‘new_user’ with the desired username and ‘password’ with the desired password. Update privileges: sql GRANT ALL…

Read More Read More