Guest User

Untitled

a guest
Nov 19th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. # Installation
  2. brew install mariadb (or mysql)
  3. mysql.server start
  4.  
  5. # Securing MariaDB
  6. mysql_secure_installation
  7.  
  8. # Connecting
  9. mysql -u root -p
  10.  
  11. mysql.server stop
  12. mysqld_safe --skip-grant-tables &
  13. mysql -u root
  14. ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
  15. SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');
  16.  
  17. CREATE USER 'username'@'host' IDENTIFIED BY 'password’;
  18. SELECT User, Host FROM mysql.user;
  19. GRANT ALL ON *.* TO ‘username’@‘host’ WITH GRANT OPTION;
  20. REVOKE ALL,GRANT OPTION FROM ‘username’@‘host’;
  21. SHOW GRANTS FOR ‘username’@‘host’;
  22. SET PASSWORD FOR ‘username’@‘host’ = PASSWORD(‘password’);
  23. DROP USER ‘username’@‘host’;
  24.  
  25. # Databases
  26. CREATE DATABASE ‘database’;
  27. SHOW DATABASES;
  28. USE ‘database’;
  29. DROP DATABASE ‘database’;
  30.  
  31. # Tables
  32. CREATE TABLE employees (
  33. id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
  34. surname VARCHAR(100),
  35. givenname VARCHAR(100),
  36. pref_name VARCHAR(50),
  37. birthday DATE
  38. );
  39.  
  40. DELETE FROM partido WHERE id_partido = 0;
  41. DESCRIBE ‘tablename’
  42. DROP TABLE ‘tablename'
  43.  
  44.  
  45. backup: # mysqldump -u root -p[root_password] [database_name] > dumpfilename.sql
  46.  
  47. restore:# mysql -u root -p[root_password] [database_name] < dumpfilename.sql
  48.  
  49.  
  50. SHOW PROCEDURE STATUS;
  51. DROP PROCEDURE carga_partido;
  52.  
  53. 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.
  54. 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.
  55. 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