Browsed by
Tag: Complete Tutorials on MySQL

How you will Create a database on the mysql server with unix shell

How you will Create a database on the mysql server with unix shell

mysql> create database databasename; To create a MySQL database on a server using the Unix shell, you can use the mysqladmin or mysql command-line tools. Here’s an example using the mysql command: Open a terminal on your Unix-based system. Log in to the MySQL server using the following command. You will be prompted to enter the MySQL user password. bash mysql -u username -p Replace “username” with your MySQL username. Once you are logged in, you can create a new…

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

Use a regular expression to find records. Use “REGEXP BINARY” to force case-sensitivity. This finds any record beginning with r

Use a regular expression to find records. Use “REGEXP BINARY” to force case-sensitivity. This finds any record beginning with r

mysql> SELECT * FROM tablename WHERE rec RLIKE “^r”; To find records beginning with “r” in MySQL with case sensitivity enforced, you would use the following query: sql SELECT * FROM your_table WHERE your_column REGEXP BINARY ‘^r’; This query uses the REGEXP BINARY operator to enforce case sensitivity, and ^r as the regular expression pattern to match any record beginning with “r”.

How to list or view all databases from the mysql server

How to list or view all databases from the mysql server

mysql> show databases. To list or view all databases in MySQL, you can use the following SQL command: sql SHOW DATABASES; When you run this command in the MySQL command-line interface or any MySQL client tool, it will display a list of all the databases available on the MySQL server.

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 Switch (select or use) to a database

How Switch (select or use) to a database

mysql> use databasename; In MySQL, you can switch (select or use) to a different database using the USE statement. Here’s the syntax: sql USE database_name; Replace database_name with the name of the database you want to switch to. This statement sets the default database for the current session. For example, if you want to switch to a database called “mydatabase,” you would execute: sql USE mydatabase; After executing this statement, any subsequent SQL statements will be executed in the context…

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 see all the tables from a database of mysql server

How to see all the tables from a database of mysql server

mysql> show tables; To see all the tables in a MySQL database, you can use the following SQL query: sql SHOW TABLES; This query will display a list of all tables in the currently selected database. If you want to see tables from a specific database, you can switch to that database using the USE statement before running the SHOW TABLES query. For example: sql USE your_database_name; SHOW TABLES; Replace your_database_name with the name of the database you want to…

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 see table’s field formats or description of table

How to see table’s field formats or description of table

mysql> describe tablename; In MySQL, you can use the DESC or DESCRIBE statement to see the description of a table, including the field formats. Here’s an example: sql DESCRIBE your_table_name; or sql DESC your_table_name; Replace “your_table_name” with the actual name of the table you want to describe. This will provide information about the columns, their data types, whether they allow NULL values, and any additional attributes. For example: sql DESCRIBE employees; This will show you the structure and details of…

Read More Read More