mysql
Installation
- VM ubuntu server
- The default login is
sudo mysqlie. only the superuser should be able to access the database - Create a user with admin priviletges and flush:
- Need to allow remote access to server by changing the bind address to 0.0.0.0 in
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnfand thenrestart mysql - Using VS Code with extension.
- install
phymyadminand then access thru browser. Save google sheet as.odsextension and can import using the phpmyadmin web interface. Make sure field names and data types are correct.
Queries
select * from table_name;
select * from table_name where column = "string";
select * from table_name where column like '%string%';
select count(*) from table_name where column like '%string%';
Primary Keys
Primary Keys
autoincrement int versus UUID
Use this code:
CREATE TABLE mytable (
id BINARY(16) PRIMARY KEY DEFAULT (UUID_TO_BIN(UUID())),
name VARCHAR(255)
);
```<br>
``` { .sql .copy }
CREATE TABLE Students(
ID int PRIMARY KEY AUTO_INCREMENT,
FirstName varchar(25) NOT NULL,
LastName varchar(25),
Age int
);
Importing data
From google sheets make sure all dates are YYYY-MM-DD and all fields match. Leave id field out so can auto fill on import.
To just export the sheet of interest alter the url of the sheet with: export?format=ods&gid ...