download mysql
goto the website
Download MySQL Community Serverdev.mysql.com
without login.
choose
macOS 10.13 (x86, 64-bit), DMG Archive
to download.install mysql
click / double-click by default to install, especially to maintain a password.start mysql
enter preference -> mysql -> start MYSQL serverconfigure mysql
add
SQL_HOME=/usr/local/mysql
PATH=$SQL_HOME/bin:$PATH
to bash_profile.
validate
source ~/.bash_profilelogin mysql
mysql -u root -p
enter passwordchange password
alter user root@localhost identified with mysql_native_password by 'newpassword'create a database
create database test;
show databases;create a table
use test;
show tables;
create table fire_tab(
fire_id INT NOT NULL AUTO_INCREMENT,
X INT NOT NULL,
Y INT NOT NULL,
FFMC FLOAT NOT NULL,
DMC FLOAT NOT NULL,
ISI FLOAT NOT NULL,
temp FLOAT NOT NULL,
RH INT NOT NULL,
wind FLOAT NOT NULL,
rain FLOAT NOT NULL,
area FLOAT NOT NULL,
PRIMARY KEY (fire_id)
);
show columns from fire_tab;delete a table
drop table fire_tabclear a table
delete from fire_tab
truncate table fire_tabadd a column to a table
alter table fire_tab add DC FLOAT NOT NULL;rearrange a column
alter table fire_tab modify DC FLOAT NOT NULL after DMCadd a record
insert into fire_tab (fire_id,X,Y,FFMC,DMC,DC,ISI,temp,RH,wind,rain,area) values(1,7,5,86.2,26.2,94.3,5.1,8.2,51,6.7,0,0)delete a record
delete from fire_tab where fire_id=1modify authority
mysql -u root -p
use mysql;
update user set host = '%' where user = 'root';
select host, user from user;
flush privileges;
or
mysql -u root -p
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
flush privileges;modify data-type of a column
alter table firetab modify column fire_id bigint