Skip to main content

Posts

Showing posts with the label mysql

How to Add an Admin User to the WordPress Database via MySQL

First, you need to login to phpMyAdmin and locate your WordPress database. (Below is a screenshot of a Hosting cPanel) Once you are in, we will be making changes to the wp_users and wp_usermeta tables. Lets go ahead and click on  wp_users  table. We need to insert our new admin user's information, so click on the Insert tab like it shows in the image above. In the insert form, add the following: ID  – pick a number (in our example, we will use the number 4). user_login  – insert the username you want to use to access the WordPress Dashboard. user_pass  – add a password for this username. Make sure to select MD5 in the functions menu (Refer to the screenshot below). user_nicename  – put a nickname or something else that you would like to refer yourself as. user_email  – add the email you want to associate with this account. user_url  – this would be the url to your website. user_registered  – select the date/time for when this user is registered. user_status  – set this to 0. displa...

Import Mysql File Using Command LIne

Import mysql file using command line on Linux needs several steps. Step 1: Upload mysql file to server You can use either ftp or scp to upload mysql file.  Step 2: Login to server  Login to server using ssh application. Example your website domain is pratama.us and username is demby. Type this command to login to your server.  ssh demby@pratama.us You can change demby to your username and pratama.us to your domain or ip address. Step 3: Import Mysql File To import your mysql file to database you can use command below: mysql -u USERNAME -p -h HOSTNAME DATABASENAME < FILENAME Example if your mysql USERNAME is demby,  HOSTNAME is localhost, DATABASENAME is dembydb and FILENAME is dembydb.sql, type this command to import. mysql -u demby -p -h localhost dembydb < dembydb.sql If you using ip address or domain as your hostname then your command become:  mysql -u demby -p -h 118.1.1.1 dembydb < dembydb.s...

Mysql Adding data to row without replacing existing data

Adding data to row without replacing existing data I  have a column  in a row with value 'White' and want to update it to 'Not White'. The following query will change the value from 'White' to 'Not White' i.e. UPDATE table SET color = CONCAT( 'Not ', color) WHERE id=1 Now the column will have the value 'Not White'. And if I want to append the new value at the end, change the parameters order in the  CONCAT()  function. UPDATE table SET color = CONCAT( color, ' Not') WHERE id=1 Now the column will have the value 'White  Not '.

Create User in MYSQL

User management is an important aspect of managing a MySQL Server. This section covers the most common user management features encountered while managing a server. Creating a New User Account To create a new user account, first log in as root. Next, use the following command to create the user. GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'some_password'; flush privileges; This command would give the new user all privileges on all databases and tables. The user could only log in from the host specified by localhost. For the changes to take effect, you must call the flush privileges; command to make the server reread the user table. The previous command is not something you would generally do. A more reasonable command line might look like this. GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON db.* TO 'username'@'localhost' IDENTIFIED BY 'password'; flush privileges; This example explicitly identifies the privileges...

Backup Mysql Database

This tip would be useful for those who are either making backup of their remote mysql database or moving their web hosting to their provider. Here’s how to export mysql DB to SQL file using command-line utility : mysqldump –user=username –password=1234 –databases your_database –opt –quote-names –complete-insert > example.sql or you can use this command : $ mysql -u username -p dbname > database.sql If the MySQL programs are not in your path, you will need to manually specify the location of the mysqldump program: $ /usr/local/mysql/bin/mysqldump -u username -p --opt dbname > database.sql Download the database.sql and keep it in a safe place (CDR, Zip disk, etc). If you need to restore your database, you can do so like this: $ mysql -u username -p databasename