1

i'm a beginner student looking for some support on my MySQL class. I was building my new database (specifically tables) through the MySQL command line, but then i realized i forgot to set the CHARSET and COLLATION for each table, i know how to update it on each table through commands, but even if there're just a few tables for this excersise, i wanted to know if there's a command to set it to the whole DATABASE without specifying it on each table.

I hope i've included the necessary details, for those who ask why i'm not using Workbench, it's because the teacher asked us Screenshots for all the tables strictly created through the command line.

Thanks a lot!

1 Answers1

-1

Although there multiple DBMS tools to do this. But in your case you can do it using the below -

CREATE DATABASE db_name CHARACTER SET utf8 COLLATE utf8  ;

You can have a look in the documentation as well - https://dev.mysql.com/doc/refman/8.0/en/charset-database.html

While creating a table you have something as below -

CREATE TABLE `test` (
  `id` int(11) NOT NULL,
  `name` varchar(48) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='test';
COMMIT;