MySQL Basics

MySQL Basics

Login to mysql
mysql -u root -p 

Create Database
create database `database_name`;

Select Database
use `database_name`;

Show All tables
show tables;

Import a mysql dump (database must exist)
mysql -u username -p database_name < dump.sql

Create user
create user 'database_name'@'%' identified by 'database_password';

Give permissions to user for a specific database
grant all privileges on database_name.* to 'database_user';


Set Change Character Set and Collation

Databases
alter database `database_name` default character set utf8 collate utf8_general_ci;

Tables
alter table `database_name` convert to character set utf8 collate utf8_general_ci;

Show Contents from a table
select * from `table_name`;
  • 0 Utilizadores acharam útil
Esta resposta foi útil?