
How to rename a table in phpMyAdmin and MySQL
October 21, 2022
How to rename a table in phpMyAdmin
Open the database and then navigate to the table you want to rename.
When the table is open, select the “Operations” menu item.
Locate the “Move table to (database.table)” section. Yes, renaming uses the same function as moving a table to another database.
Enter a new table name and click the “Go” button.
Now the table has been given a new name.
How to rename a table in MySQL
To connect to MySQL or MariaDB DBMS on localhost without a password, use the command:
mysql -u root
To connect to MySQL or MariaDB DBMS on localhost with a password, use the command:
mysql -u root -p
Note that you do not need to specify a password after the -p option – you will need to enter the password at the command prompt.
If you are connecting to a remote server, then you can also use the -h (or --host=NAME) option with the host name or IP address.
After connecting to MySQL/MariaDB you can use the following command:
RENAME TABLE `DATABASE`.`TABLE NAME` TO `DATABASE`.`NEW TABLE NAME`;
You can also choose which database to use and leave out the database name next to the table name:
USE `DATABASE`; RENAME TABLE `TABLE NAME` TO `NEW TABLE NAME`;
An example of renaming a table in MySQL:
RENAME TABLE `test`.`OLD NAME` TO `test`.`NEW NAME`;
An example of renaming a table in MySQL with database preselection:
USE `test`; RENAME TABLE `OLD NAME` TO `NEW NAME`;
To list tables, use the following SQL query:
SHOW TABLES;
Related articles:
- “Failed - Network error” when exporting from phpMyAdmin (SOLVED) (100%)
- How to save MySQL query results in a new table (91.4%)
- How to change default export settings in phpMyAdmin (79.1%)
- Errors “Incorrect definition of table mysql.event: expected column 'definer' at position 3 to have type varchar(, found type char(141)” and “Event Scheduler: An error occurred when initializing system tables. Disabling the Event Scheduler” (SOLVED) (70.5%)
- Password and unix_socket authentication in MySQL and MariaDB. Error “#1698 - Access denied for user ‘root’@’localhost’” (SOLVED) (66.5%)
- How to set up Python as a CGI module in Apache on Debian (Ubuntu, Linux Mint) (RANDOM - 52.4%)