[−][src]Struct sqlx::mysql::MySqlConnectOptions
mysql
only.Options and flags which can be used to configure a MySQL connection.
A value of PgConnectOptions
can be parsed from a connection URI,
as described by MySQL.
The generic format of the connection URL:
mysql://[host][/database][?properties]
Properties
Parameter | Default | Description |
---|---|---|
ssl-mode | PREFERRED | Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated. See MySqlSslMode . |
ssl-ca | None | Sets the name of a file containing a list of trusted SSL Certificate Authorities. |
statement-cache-capacity | 100 | The maximum number of prepared statements stored in the cache. Set to 0 to disable. |
socket | None | Path to the unix domain socket, which will be used instead of TCP if set. |
Example
// URI connection string let conn = MySqlConnection::connect("mysql://root:password@localhost/db").await?; // Manually-constructed options let conn = MySqlConnectOptions::new() .host("localhost") .username("root") .password("password") .database("db") .connect().await?;
Implementations
impl MySqlConnectOptions
[src]
pub fn new() -> MySqlConnectOptions
[src]
mysql
only.Creates a new, default set of options ready for configuration
pub fn host(self, host: &str) -> MySqlConnectOptions
[src]
mysql
only.Sets the name of the host to connect to.
The default behavior when the host is not specified, is to connect to localhost.
pub fn port(self, port: u16) -> MySqlConnectOptions
[src]
mysql
only.Sets the port to connect to at the server host.
The default port for MySQL is 3306
.
pub fn socket(self, path: impl AsRef<Path>) -> MySqlConnectOptions
[src]
mysql
only.Pass a path to a Unix socket. This changes the connection stream from TCP to UDS.
By default set to None
.
pub fn username(self, username: &str) -> MySqlConnectOptions
[src]
mysql
only.Sets the username to connect as.
pub fn password(self, password: &str) -> MySqlConnectOptions
[src]
mysql
only.Sets the password to connect with.
pub fn database(self, database: &str) -> MySqlConnectOptions
[src]
mysql
only.Sets the database name.
pub fn ssl_mode(self, mode: MySqlSslMode) -> MySqlConnectOptions
[src]
mysql
only.Sets whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server.
By default, the SSL mode is Preferred
, and the client will
first attempt an SSL connection but fallback to a non-SSL connection on failure.
Example
let options = MySqlConnectOptions::new() .ssl_mode(MySqlSslMode::Required);
pub fn ssl_ca(self, file_name: impl AsRef<Path>) -> MySqlConnectOptions
[src]
mysql
only.Sets the name of a file containing a list of trusted SSL Certificate Authorities.
Example
let options = MySqlConnectOptions::new() .ssl_mode(MySqlSslMode::VerifyCa) .ssl_ca("path/to/ca.crt");
pub fn statement_cache_capacity(self, capacity: usize) -> MySqlConnectOptions
[src]
mysql
only.Sets the capacity of the connection's statement cache in a number of stored distinct statements. Caching is handled using LRU, meaning when the amount of queries hits the defined limit, the oldest statement will get dropped.
The default cache capacity is 100 statements.
pub fn charset(self, charset: &str) -> MySqlConnectOptions
[src]
mysql
only.Sets the character set for the connection.
The default character set is utf8mb4
. This is supported from MySQL 5.5.3.
If you need to connect to an older version, we recommend you to change this to utf8
.
pub fn collation(self, collation: &str) -> MySqlConnectOptions
[src]
mysql
only.Sets the collation for the connection.
The default collation is derived from the charset
. Normally, you should only have to set
the charset
.
Trait Implementations
impl Clone for MySqlConnectOptions
[src]
fn clone(&self) -> MySqlConnectOptions
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl ConnectOptions for MySqlConnectOptions
[src]
type Connection = MySqlConnection
fn connect(
&self
) -> Pin<Box<dyn Future<Output = Result<<MySqlConnectOptions as ConnectOptions>::Connection, Error>> + Send>> where
<MySqlConnectOptions as ConnectOptions>::Connection: Sized,
[src]
&self
) -> Pin<Box<dyn Future<Output = Result<<MySqlConnectOptions as ConnectOptions>::Connection, Error>> + Send>> where
<MySqlConnectOptions as ConnectOptions>::Connection: Sized,
impl Debug for MySqlConnectOptions
[src]
impl Default for MySqlConnectOptions
[src]
fn default() -> MySqlConnectOptions
[src]
impl FromStr for MySqlConnectOptions
[src]
Auto Trait Implementations
impl RefUnwindSafe for MySqlConnectOptions
impl Send for MySqlConnectOptions
impl Sync for MySqlConnectOptions
impl Unpin for MySqlConnectOptions
impl UnwindSafe for MySqlConnectOptions
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,