Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Installation
- brew install mariadb (or mysql)
- mysql.server start
- # Securing MariaDB
- mysql_secure_installation
- # Connecting
- mysql -u root -p
- mysql.server stop
- mysqld_safe --skip-grant-tables &
- mysql -u root
- ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
- SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
- CREATE USER 'username'@'host' IDENTIFIED BY 'password’;
- SELECT User, Host FROM mysql.user;
- GRANT ALL ON *.* TO ‘username’@‘host’ WITH GRANT OPTION;
- REVOKE ALL,GRANT OPTION FROM ‘username’@‘host’;
- SHOW GRANTS FOR ‘username’@‘host’;
- SET PASSWORD FOR ‘username’@‘host’ = PASSWORD(‘password’);
- DROP USER ‘username’@‘host’;
- # Databases
- CREATE DATABASE ‘database’;
- SHOW DATABASES;
- USE ‘database’;
- DROP DATABASE ‘database’;
- # Tables
- CREATE TABLE employees (
- id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
- surname VARCHAR(100),
- givenname VARCHAR(100),
- pref_name VARCHAR(50),
- birthday DATE
- );
- DELETE FROM partido WHERE id_partido = 0;
- DESCRIBE ‘tablename’
- DROP TABLE ‘tablename'
- backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
- restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
- SHOW PROCEDURE STATUS;
- DROP PROCEDURE carga_partido;
- If you're doing this only once, and the table is empty to start, you could run the import but first alter your table so the date column is of type VARCHAR. Then run UPDATE table SET date = str_to_date( date, '%m/%d/%Y'), and convert the column back to DATETIME or DATE.
- You could alternatively add a second date column with format DATE, import into the first date column in format VARCHAR, and run UPDATE table SET date2 = str_to_date( date1, '%m/%d/%Y') and then DROP the varchar column.
- It's important to note that the second parameter of STR_TO_DATE() is the inputted format, not the resulting format. So in your second parameter, you're instructing MySQL that the date format in the CSV is Y-m-d. If it is in fact m/d/Y, you ought to be using `STR_TO_DATE(@date_date, '%m/%d/%Y)'.
Add Comment
Please, Sign In to add comment